#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
// const int N = 1e
int main(){
int n;
scanf("%d",&n);
while(n--){
int a,b;
scanf("%d%d",&a,&b);
int ans = __gcd(a,b);
cout << ans << endl;
}
return 0;
}