In this HackerRank itertools.product() problem you are given two lists A and B. your task is to compute their cartesian product AxB and print that on the screen.

HackerRank itertools.product() in python problem solution

HackerRank itertools.product() in python problem solution

# Enter your code here. Read input from STDIN. Print output to STDOUT
from itertools import product
l = [map(int, raw_input().split()), map(int, raw_input().split())]
a = list(product(*l))
for i in range(len(a)):
    print a[i],
print

Second solution

from itertools import product
a = {int(i) for i in input().split()}
b = {int(i) for i in input().split()}
print(" ".join(map(str,product(a,b))))