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


/*
USER:
TASK:
ALGO:
*/
/*
#pragma warning (disable: 4786)
#pragma comment (linker, "/STACK:0x800000")
*/
/*#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>*/
#include<bits/stdc++.h>

#define INF_MAX     2147483647
#define INF_MIN     -2147483648
#define INF         (1 << 30)
#define EPS         1e-9
#define N           2 + 1000000
#define MOD         10000000007
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define Pi acos(-1.0)
#define MP(x, y) make_pair(x, y)
#define REV(s, e) reverse(s, e)
#define SET(p) memset(p, -1, sizeof(p))
#define CLR(p) memset(p, 0, sizeof(p))
#define MEM(p, v) memset(p, v, sizeof(p))
#define CPY(d, s) memcpy(d, s, sizeof(s))
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define SZ(c) (int)c.size()
#define PB(x) push_back(x)
#define ff first
#define ss second
#define i64 long long
#define ld long double
#define pii pair< int, int >
#define psi pair< string, int >
#define ALL(c) (c).begin(),(c).end()
#define REP(i, n) for(int i=0; i<(int)n; ++i)
#define rep(i,a,b)  for(int i=(a); i<(b); i++)
#define repC(i,x)   for(size_t i=0; i<x.size(); i++)
#define FOR(i, c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
using namespace std;

template< class T > T _abs(T n) { return (n < 0 ? -n : n); }
template< class T > T _max(T a, T b) { return (!(a < b) ? a : b); }
template< class T > T _min(T a, T b) { return (a < b ? a : b); }
template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template <class T> string toStr(const T &x)
{ stringstream s; s << x; return s.str(); }

template <class T> int toInt(const T &x)
{ stringstream s; s << x; int r; s >> r; return r; }

template<class T> string itoa(T a)
{
    if(!a) return "0";
    string ret;
    for(T i=a; i>0; i=i/10) ret.PB((i%10)+48);
    reverse(ALL(ret));
    return ret;
}
#define on(n,pos) (n | (1LL<<(pos)))
#define off(n,pos) n & ~(1LL<<pos)
#define isOn(n,pos) (bool)(n & (1LL<<(pos)))

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int a, b, gcd = 0;

    while(cin>>a>>b)
    {
        for(int i = 1; i <= a && i <= b; i++)
        {
            if(a % i == 0 && b % i == 0)
            {
                gcd = i;
            }
        }
        cout<<gcd<<endl;
        gcd = 0;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){

int x,y,z;

cin >> x >> y;

while(true){
if(x > y){
z = x % y;
x = x - z;
}
if(y > x){
z = y % x;
y = y - z;
}
if(z == x || z == y)break;
}

cout << x;

}

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

using namespace std;

int get(int, int);

int main(int argc, char *argv[]) {
  int x, y;

  while (cin >> x >> y)
    cout << getLCM(x, y) << endl;
  return 0;
}

int get(int x, int y) {
  int tmp;

  if (x < y) {
    tmp = y;
    y = x;
    x = tmp;
  }
  while (x % y != 0) {
    tmp = x % y;
    x = y;
    y = tmp;
  }
  return y;
}

C++: #include<iostream>

using namespace std;
int euclid(int n, int m);

int main(){
  int n,m;
  while(cin>>n>>m){
    cout <<euclid(n,m<<endl;
  }
}

int euclid(int n,int m){
  if(n<m){
  int temp;
  temp=m;
  m=n;
  n=temp;
  }
  if(n%m==0){
    return m;
  }else{
    return euclid(m,n%m);
  }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;
  while(cin >> a >> b){
    cout << gcd(a,b)<<endl;
  }
  return 0;
}

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

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
int main(){
    int a,b;
    while(cin>>a>>b){
        if(a<b)swap(a,b);
        for(int i=a;i>1;i--){
            if(b%i==0&&a%i==0){
                cout<<i<<endl;
                break;
            }
        }
    }
}

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

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

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int a,b,k;
int main(){
  while(~scanf("%d %d",&a,&b)){
    k=0;
    for(int i=1;i<=min(a,b);i++){
      if(a%i==0&&b%i==0){k=i;}
    }
    printf("%d\n",k);    
  }
}

C++: #define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

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


using namespace std;

int y[100005];

int main() {
	

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

	return 0;

}

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

int gcd( int x, int y){
  int r;
  if( x < y ) swap(x,y);

  while( y > 0 ){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

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

  return 0;
}