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