def gcd(a, b): if a > b: a, b = b, a while a: a, b = b%a, a return b n = int(input()) for _ in range(n): a, b = map(int, input().split()) print(gcd(a, b))