itertools.product()

  • + 0 comments

    A = sorted(map(int,input().split())) B = sorted(map(int,input().split()))

    cartesian_product = [(a, b) for a in A for b in B]

    print(" ".join(f"({a}, {b})" for a, b in cartesian_product))