#include <iostream>
using namespace std;
int gcd(int a, int b){
while(a%b){
int r = a%b;
a = b;
b = r;
}
return b;
}
int main(){
int n;
cin >> n;
for (int i = 1; i <= n; i ++ ){
int a, b;
cin >> a >> b;
cout << gcd(a, b) << endl;
}
return 0;
}