# HackerRank itertools.product() solution in python

In this HackerRank itertools.product() problem solution in python This tool computes the cartesian product of input iterables.

It is equivalent to nested for-loops. You are given a two lists A and B. Your task is to compute their cartesian product A X B.

## Problem solution in Python 2 programming.

```from itertools import product

A = map(int,raw_input().split())
B = map(int,raw_input().split())
print " ".join(str(k) for k in product(A,B))```

## Problem solution in Python 3 programming.

```# Enter your code here. Read input from STDIN. Print output to STDOUT

from itertools import product
a = map(int, input().split())
b = map(int, input().split())

print(*product(a, b))```

### Problem solution in pypy programming.

```from itertools import product
flist = map(int, raw_input().split())
slist = map(int, raw_input().split())

for item in product(flist, slist):
print tuple(item), ```

### Problem solution in pypy3 programming.

```import itertools
# Enter your code here. Read input from STDIN. Print output to STDOUT
A = list(map(int,input().split()))
B = list(map(int,input().split()))

p = list(itertools.product(A,B))
print(" ".join(map(str,p)))```