Enumerating the Cartesian product