#include<bits/stdc++.h>using namespace std;int main(){ int n,m; while(cin>>n>>m){ while(n!=0 && m!=0) (n>m) ? n=n%m : m=m%n; (n==0) ? cout<<m<<endl : cout<<n<<endl; }}