<reponame>LikimiaD/HackerRank<gh_stars>0
from itertools import product
print(*product(map(int, input().split(' ')), map(int, input().split(' '))))
from itertools import product
print(*product(map(int, input().split(' ')), map(int, input().split(' '))))