Input Format
The first line contains the space separated elements of list .
The second line contains the space separated elements of list .
Both lists have no duplicate integer elements.
Constraints

Output Format
Output the space separated tuples of the cartesian product.

hackerrank itertools product() problem solution in python programming

Problem solution in python 2 programming language.

from itertools import product

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

for item in product(A,B):
    print(item,end=' ')

Problem solution in python 3 programming language.

from itertools import product

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

for item in product(A,B):
    print(item,end=' ')