Each trit of m picks a copy, a zero or a flip of n, shifted one place per row. Add the rows: that is the product.
This widget runs in your browser and needs JavaScript.