#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a, b;
int gcd(int a, int b) //辗转相除
{
return b != 0 ? gcd(b, a % b) : a;
}
int main()
{
int T;
cin >> T;
while(T --)
{
cin >> a >> b;
cout << gcd(a, b) << endl;
}
return 0;
}