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++: 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;
}

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

C++: //28
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int h,l;cin>>h>>l;){
    if(h<l){
      swap(h,l);
    }
    while(h%l){
      h%=l;
      swap(h,l);
    }
    cout<<l<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
main(){int a,b;while(~scanf("%d%d",&a,&b)){printf("%d\n",std::__gcd(a,b));}}

C++: #include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

long long gcd(long long a, long long b){ // Ååöñ
    while(b != 0){
        long long tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

int main()
{
    for(;;){
        int a, b;
        if(!(cin >> a >> b))
            return 0;

        cout << gcd(a, b) << endl;
    }
}

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

int main()
{
  int n, m;
  int k;
  while (cin >> n >> m)
  {
    if (n<m) swap(n,m);
    while (m>0)
    {
      k=n; n=m; m=k % m;
    }
    cout << n << endl;
  }
  return 0;
}

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

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

C++: #include<bits/stdc++.h>
main(){int a,b;while(~scanf("%d%d",&a,&b)){printf("%d\n",std::__gcd(a,b));}}

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

int gcd(int x, int y){
    if( x < y ){
        int t = x;
        x = y;
        y = t;
    }
    while( x%y ){
        int t = x%y;
        x = y;
        y = t;
    }
    return y;
}

int main(){
    int a, b;
    while( cin >> a >> b ) cout << gcd(a, b) << 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>
using namespace std;

int main(){
	long long int a,b,c;
	while(cin >> a >> b){
		if(a != 0 && b != 0)while(1){
			if(a<b){
				c = b%a;
			}
			else {
				c = a%b;
			}
			if(c!=0){
				a = b;
				b = c;
			}
			else {
				break;
			}
		}
		if(a != 0 && b != 0){
			cout << b << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

int euklides(int a, int b) {
    while (a % b!= 0) {
        int tmp = b;
        b = a % b;
        a = tmp;
    }
    return b;
}

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

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

using namespace std;

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

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

int main()
{
	solve();
	return(0);
}

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

int GCD(int a, int b) {
	if (a < b) swap(a, b);
	a = a % b; return (a == 0 ? b : GCD(a, b));
}

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

C++: #include <stdio.h>

int main(){
int x,y;

int byakko(int x, inty){
x > y ? return x % y : return y % x;
}

while(scanf("%d %d", &x, &y)){
cout << byakko(x, y) << endl;
}
}

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

int Egcd(int x, int y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return Egcd(y, x % y);
}

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

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

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

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

C++: #include <iostream>

using namespace std;
int main(){
	int a,b,ret;
	while(cin>>a>>b, !cin.eof()){
		if(a==0 || b==0) ret = 0;
		else if(a>=b){
			while(b!=0){
				ret = b;
				b = a%b;
				a = ret;
			}
			ret = a;
		}else{
			while(a!=0){
				ret = a;
				a = a%b;
				b = ret;
			}
			ret = b;
		}
		cout<<ret<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

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

int main(){

  int a,b;

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

C++: #include<stdio.h>
 
int main(){
	int a, b, n;
	while(scanf("%d %d", &a, &b) != EOF){
		if(a <= b){
			n = a;
			a = b;
			b = n;
		}
		if(a % b == 0) n = b;
		while(a % b != 0){
			if(a % b == 0){
				n = b;
				break;
			}
			a = a % b;
			n = a;
			a = b;
			b = n;
		}
		printf("%d\n", n);
	}
	return 0;
}

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

int main(){
	long long int a,b,c;
	while(cin >> a >> b){
		while(1){
			if(a<b){
				c = b%a;
			}
			else {
				c = a%b;
			}
			if(c!=0){
				a = b;
				b = c;
			}
			else {
				break;
			}
		}
		cout << b <<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}


int main(){
    int a,b;
    while (cin >> a >> b){
        //cin >> a >> b;
        cout << GCD(max(a,b),min(a,b)) << endl;
    }
}