a, b, lst = 20, int(input("b=")), []
for i in range(a):
x = float(input())
if x % b == 0:
lst.append(x)
print(*lst)
a, b, lst = 20, int(input("b=")), []
for i in range(a):
x = float(input())
if x % b == 0:
lst.append(x)
print(*lst)