from functools import reduce
import operator


def crossproduct(ss, row=None, level=0):
    """Returns the cross-product of the sets given in `ss`."""
    if row is None:
        row = []
    if len(ss) > 1:
        return reduce(operator.add,
                      [crossproduct(ss[1:], row + [i], level + 1) for i in ss[0]])
    else:
        return [row + [i] for i in ss[0]]