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 <iostream>
#include <cstdio>

using namespace std;

void swap(int *x, int *y){
	int tmp=*x;
	*x=*y;
	*y=tmp;
}

int main(){
	long a, b;
	while( scanf(" %ld %ld", &a, &b) != EOF ){
		if(a<b) swap(a,b);
		
		if(b!=0){
			while(b!=0){
				long r=a%b;
				a=b;
				b=r;
			}
		}
		printf("%ld\n", a);
	}
	
	return 0;
}

C++: 
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int gcd(int a,int b){
    if(b == 0)return a;
    else return gcd(b,a%b);
}
int main() {
    int a,b;
    while(cin >> a >> b){
        cout << gcd(a, b) << endl;
    }
    return 0;
}

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


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

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

C++: #include<algorithm>
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b)cout<<__gcd(a,b)<<endl;
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
int GCD(int a, int b){
    if(b==0) return a;
    return GCD(b, a%b);
}

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

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);
  }
  return 0;
}

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



using namespace std;


int main(){
  int a,b;
  while (std::cin >> a>>b) {
    if(b>a){
      int t=b;
      b=a;
      a=t;
    }
    while (a%b!=0) {
      int p=a%b;
      a=b;
      b=p;
    }
    std::cout << b << '\n';
  }
}

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

int main(){
	int n, m;

	while(cin >> n >> m){
		if(n < m) swap(n, m);

		while(n % m != 0){
			int d = n % m;
			n = m;
			m = d;
		}
		cout << m << endl;
	}
}

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>

using namespace std;

int main(int argc, char **argv)
{
	int *a, *b, s, t, c;
	int p, q;
	a = &p;
	b = &q;
	while(cin >> p >> q){
		s = *a;
		t = *b;
		c = 1;
		for(int tmp = (*a > *b)? *b : *a, i = 2; i <= tmp; i++){
			while(s%i == 0 && t%i == 0){
				s /= i;
				t /= i;
				tmp /= i;
				c *= i;
			}
		}
		cout << c << " " << endl;
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <cmath>
#include <cassert>
using namespace std;

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

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

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

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

int main() {
  int x, y;

  while(cin >> x >> y) {
    if(x < y) swap(x, y);
    int ans = gcd(x, y);
    cout<< ans << endl;
  }
}

C++: #include <iostream>

using namespace std;
int main(){
	int a,b,ret;
	while(cin>>a>>b, !cin.eof()){
		ret = 0;
		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 <iostream>

int main(){
	int a, b;
	while(std::cin >> a >> b, !std::cin.eof()){
		while(b){
			int c = b;
			b = a % b, a = c;
		}
		std::cout << a << std::endl;
	}
}

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


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

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

C++: #include <stdio.h>
#include <string.h>

int gcd(unsigned long int a,unsigned long int b)
{
    if(b == 0)
       return a;
    else
       return gcd(b, a % b);
}
int main()
{
    unsigned long int a,b;
    scanf("%ul%ul",&a,&b);
    
    printf("%d",gcd(a,b));
    
    

    return 0; 

}

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

using namespace std;

void change(int *, int *);

int main(void)
{
	int x, y;
	
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0)
		break;
		if(x < y)
			change(&x, &y);
		while(y){
			x %= y;
			change(&x, &y);
		}
		cout << x << endl;
	}
	return 0;
}

void change(int *a, int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
	
}

C++: #include<iostream>
using namespace std;
int main(){
	int x,y,i,j,k,c,s,d,gcd=0;
	for(i=1;i<50;i++){
		cin>>x>>y;
		if(x>y){
			for(j=1;j<=x;j++){
				k=x%j;
				c=y%j;
				if(k==0&&c==0){
					gcd=j;
				}
				if(j==x){
					cout<<gcd<<endl;
				}
			}
		}else{
			for(j=1;j<=y;j++){
				s=x%j;
				d=y%j;
				if(s==0&&d==0){
					gcd=j;
				}
				if(j==y){
					cout<<gcd<<endl;
				}
			}
		}

	}
	return 0;
}