We can avoid a level of nesting here by using itertools.product.