#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
int main()
{
int n;
cin>>n;
while(n--)
{
int a,b;
scanf("%d%d",&a,&b);
auto t=gcd(a,b);
printf("%d\n",t);
}
return 0;
}
hh