Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for {
		if sc.Scan() == false {
			break
		}
		str := sc.Text()
		cols := strings.Split(str, " ")
		n, _ := strconv.Atoi(cols[0])
		m, _ := strconv.Atoi(cols[1])
		var gcd int
		if n > m {
			gcd = getGcd(n, m)
		} else {
			gcd = getGcd(m, n)
		}
		fmt.Println(gcd)
	}
}

func getGcd(n int, m int) int {
	var mod int
	nn := n
	mm := m
	for {
		mod = nn % mm
		if mod == 0 {
			break
		}
		nn = mm
		mm = mod
	}
	return mm
}

C++: #include <cstdlib>
#include <iostream>
using namespace std;

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	for(int a, b; cin >> a >> b;) {
		cout << __gcd(a, b) << endl;
	}

	return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());

int gcd(int a,int b){
	if(0==b) return a;
	return gcd(b,a%b);
}


int main(){
	int a,b;
	while(cin>>a){
		cin>>b;
		if(a>b) swap(a,b);
		cout<<gcd(a,b)<<endl;
	}
}

C++: #include<iostream>
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}

int main(){
    int x, y;
    while(cin >> x >> y)    cout << gcd(x,y) << endl;
    return 0;
}

C++: #include <iostream>
using namespace std;

int gcd(int m, int n);

int main(int argc, const char * argv[])
{
    //std::cout << "Hello World\n";
    int n, m;
    while(cin >> n >> m){
        //std::cout << n << "," << m << "\n";
        cout << gcd(n, m) << "\n";
    }
    return 0;
}

int gcd(int m, int n){
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main()
{
  int a, b;

  while (cin >> a >> b){
    if (a < b)  swap(a, b);
    while (b != 0){
      int r = a % b;
      a = b;
      b = r;
    }
    cout << a << endl;
  }
  return (0);
}

C++: #include<iostream>
#include<cstdio>
using namespace std;

unsigned int euclid(unsigned int a,unsigned int b){
  if(b==0) return a;
  return euclid(b,a%b);
}

int main(void){
  unsigned int a,b;
  while(scanf("%u %u",&a,&b)!=0) cout<<euclid(a,b)<<endl;
  return 0;
}

C++: #include<iostream>
 
using namespace std;
 
int GCD(int M, int N) {
     
    while(N != 0) { 
        int r = M % N; 
        M = N; 
        N = r; 
    } 
    return M;
}
 
int main() { 
    int m, n; 
 
    while(cin >> m >> n) {
 
    cout << GCD(m, n) << "\n"; 

}
     
    return 0; 
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);

	int ma = max(a, b);
	int mi = min(a, b);
	int rem;

	while (1){
		rem = ma % mi;
		if (rem == 0){
			break;
		}
		ma = mi;
		mi = rem;
	}

	cout << mi << endl;

	return (0);
}

C++: #include<iostream>
using namespace std;

int gcd(int x, int y) {
	if (y == 0) return x;
	else return gcd(y, x % y);
}

int main(){
    int a, b;
    while( scanf("%d %d", &a, &b) != EOF ){
        cout<<gcd(a,b)<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

int gcd(int x, int y){
	return y ? gcd(y,x%y) : x;
}
int main(){
	int a,b;
	while(~scanf("%d%d",&a,&b)){
		printf("%d\n",gcd(a,b));
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int a,b;
while(cin>>a>>b){
if(a<b)swap(a,b);
while(b){
a=a%b;
swap(a,b);
}
cout<<a<<endl;
}
}

C++: #include <iostream>

int eucgcd(int m, int n)
{
	if( n == 0 )
		return m;
	else 
		return eucgcd( n, m%n );
}


int main()
{
	int m,n;
	
	while( std::cin >> m >> n, (m||n) )
	{
		if( m >= n )
			std::cout << eucgcd(m, n) << std::endl;
		else
			std::cout << eucgcd(n, m) << std::endl;
	}
	
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int a,b;
int main(){
  while(scanf("%d %d",&a,&b)!=EOF){
    for(int i=min(a,b);i>0;i--){
      if(a%i==0 && b%i==0){
        printf("%d\n",i);
        break;
      }
    }
  }
return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

long long gcd(long long a, long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(){
    
    long long a,b;
    while(cin>>a){
        cin>>b;
        cout<<gcd(a,b)<<endl;
    }
    
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	long long a,b;
	while(cin>>a>>b){
		while(true){
			if(a>b)
				a-=b;
			if(a<b)
				b-=a;
			if(a==b)
				break;
		}
		cout<<a<<endl;
	}
    return 0;
}

C++: #include <iostream>
using namespace std;

int gcm(int a, int b)
{
  if (a > b)
  {
    int tmp = a;
    a = b;
    b = tmp;
    cerr << 'a' << endl;
  }

  for (int i = 1; ; ++i)
  {
    if (a % i == 0 and b % (a / i) == 0 )
    {
      return a / i;
    }
  }
}

int main(void)
{
  int a, b;
  while (cin >> a >> b)
  {
    cout << gcm(a, b) << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<math.h>
#include<cstdio>
using namespace std;
int main(){
	while(1){
		long long a,b;
		cin>>a>>b;
		long temp;
		if(a<b){temp=a;a=b;b=temp;}
		if(cin.eof()) {break;}
		long q,r;
		while(a%b!=0){
			q=(long long)a/b;		
			r=(long long)a%b;
			a=b;
			b=r;
		}
		cout<<b<<endl;		
	}
	return 0;	
}

C++: #include<iostream>

using namespace std;

int main(void){

	int a,b;

	while(cin>>a>>b){
		for(int i=100000;i>=0;i--){
			if(a%i==0&&b%i==0){
				cout<<i<<endl;
				break;
			}
		}
	}
}

C++: #include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>
#include<list>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




void solve(){
	int a,b;
	while(cin >> a >> b){
		cout << __gcd(a,b) << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}