def gcd(a, b): return a if b == 0 else gcd(b, a % b) n = int(input()) for sdf in range(n): s = input().split(' ') a, b = map(int, s) print(gcd(a, b))