n = int(input())
k = int(input())
res = 1
for i in range(n):
a = int(input())
if(a % k != 0):
res = res * a
print(res)
n = int(input())
k = int(input())
res = 1
for i in range(n):
a = int(input())
if(a % k != 0):
res = res * a
print(res)