#include <bits/stdc++.h>
using namespace std;
int n;
int gcd(int x, int y){
if(x%y==0) return y;
return gcd(y, x%y);
}
int main(){
cin>>n;
int x,y;
while(n--){
cin>>x>>y;
cout<<gcd(x, y)<<endl;
}
return 0;
}