a,b = map(int,input().split())
s = []
for i in range(1,max(a,b)):
if a % i == 0 and b % i == 0:
s.append(i)
print(s[len(s)-1])
a,b = map(int,input().split())
s = []
for i in range(1,max(a,b)):
if a % i == 0 and b % i == 0:
s.append(i)
print(s[len(s)-1])