Combinatorial helpers.
Cartesian product of lists: every way to pick one element from each inner list, preserving order. The result size is the product of the inner list sizes.