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 <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;
#define EPS (1e-6)
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef pair<int,int> P;

int gcd( int a, int b )
{
  int c;
  while ( a != 0 ) {
    c = a; a = b%a;  b = c;
  }
  return b;
}

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);
  int INF = 1000000;

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

  return 0;
}

C++: #include<cstdio>

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

int main(){
	for(int a,b;~scanf("%d%d",&a,&b);)	printf("%d\n",gcd(a,b));
	return 0;
}

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

int main()
{
    int a, b;
    
    while(scanf("%d%d", &a, &b) != EOF)
    {
        printf("%d\n", std::__gcd(a, b));
    }
    
    return 0;
}

C++: #include <iostream>

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) {
            int t; t = a; a = b; b = t;
        }
        cout << gcd(a, b) << endl;
    }
    return 0;
}

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

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

int main()
{
	int m,n;
	
	scanf("%d %d", &m, &n);
	if(m < n) swap(m,n);
	
	while(n != 0){
		int t=n;
		n = m%n;
		m = t;
	}
	
	printf("%d\n", m);
	return (0);
}

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

int gcm(int a, int b)
{
  if (a > b)
  {
    int tmp = a;
    a = b;
    b = tmp;
  }

  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 <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(void) {
	int p, q;
	while((scanf("%d %d", &p, &q)) == 2) {
		if(q > p) swap(p, q);
		while(q != 0)
			swap(p %= q, q);
		printf("%d\n", p);
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
	int x,y,z;
	while(scanf("%d%d",&x,&y)>0)
	{
		while(z=x%y)x=y,y=z;
		printf("%d\n",y);
	}
	return 0;
}

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

int main(void){
	int a,b;
	whilecin>>a>>b)
	cout<<__gcd(a,b)<<endl;
}

C++: #include <iostream>
ing main()
{
long int a, b, i, maks;
cin >> a >> b;
if (a > b) maks = a;
else maks = b;
for (i=2;i<=maks;i++)
if (maks % a == 0 && maks % b == 0)
{
cout << i << endl;
break;
}
return 0;
}

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

int solve(int a, int b){
    int r;
    r = a % b;

    if(r == 0){
        return b;
    }else{
        return solve(b, r);
    }
}

int main(){
    int a, b;
    int gcd, lcm;

    while(cin >> a >> b){
        gcd = solve(a, b);

        cout << gcd << endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

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

void solve()
{
	int m, n;
	while(cin >> m >> n)
	{
		if(m < n)
		{
			swap(m, n);
		}
		cout << gcd(m, n) << endl;;
	}
}

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

C++: #include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#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>
#include <functional>
#include <cctype>

using namespace std;

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

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

int main()
{
	int A, B;
	while(cin >> A >> B)
		cout << gcd(A, B) << endl;

	return 0;
}

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

int main(){
  int a, b;
  while( scanf("%d %d", &a, &b ) == 2 ){
    while( a != b ){
      if( a > b )
	a -= b;
      else
	b -= a;
    }
    printf("%d\n", a);
  }
  return 0;
}

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

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

using namespace std;

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

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

using namespace std;


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

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 ){
	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[])
{
    int n, m;
    while(cin >> n >> m){
        cout << gcd(m, n) << "\n";
    }
    return 0;
}

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

C++: #include <cstdio>
#include <cctype>
#include <utility>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int a, b; scan(a, b);)
		outl(__gcd(a, b));
}