#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
	 if(b==0)return a;
	 return gcd(b,a%b);
 }
int main(){
	int a,b;
	while(1){
		cin>>a>>b;
		if(a==0&&b==0)break;
		cout<<gdc(a,b)<<endl;
	}
}