#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define i27 __int128
using namespace std;
const ll NMAX=5e2+5;
const ll NMAX2=1+5;
const double eps=1e-8;
const ll TIME_MAX=9e8+5;
const ll MOD=666013;
const ll PLUS=1e5;
const ll K=300;
ll get_time(){
return chrono::steady_clock::now().time_since_epoch().count();
}
/*vector<int> v;
bitset<NMAX> c;
void ciur(){
c[0]=c[1]=1;
for(ll i=2;i<NMAX;i++){
if(c[i]==0){
v.push_back(i);
for(ll j=i;j<NMAX;j+=i){
c[j]=1;
}
}
}
}
vector<int> tp;*/
void probleme(){
ll a,b;
cin>>a>>b;
cout<<__gcd(a,b)<<'\n';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef LOCAL
freopen("thing2.in","r",stdin);
freopen("thing2.out","w",stdout);
#else
freopen("euclid2.in","r",stdin);
freopen("euclid2.out","w",stdout);
#endif
ll start=get_time();
ll t; cin>>t; while(t--)
probleme();
ll x=get_time()-start;
cerr<<"------>secunde - "<<x/1000000000<<'\n';
cerr<<"-->milisecunde - "<<x/1000000%1000<<'\n';
cerr<<"->microsecunde - "<<x/1000%1000<<'\n';
cerr<<"-->nanosecunde - "<<x%1000;
return 0;
}