a,b=map(int,input().split())
while b:
 a,b=b,a%b
print(a) a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b while b:
 a,b=b,a%b b a,b=b,a%b a b b a%b a b print(a) print a b=b,a%b a%b b a,b=map(int,input().split()) map(int,input().split()) a b=map(int,input().split()) map(int,input().split()) b a,b=b,a%b b a
a,b=map(int,input().split())
while b:
 a,b=b,a%b
print(a)