from itertools import product

def gen(l):
	return map(list, product(*map(range, l)))

print(list(gen([1, 2, 3])))