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++: package com.practice.takuya._1009;

import java.io.BufferedReader;
import java.io.InputStreamReader;




public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String line = br.readLine();
			
			System.out.println(getGreatestCommonDivisor(line));
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static int getGreatestCommonDivisor(String line) {
		
		String[] splitedArray = line.split(" ", 0);
		int x = Integer.valueOf(splitedArray[0]).intValue();
		int y = Integer.valueOf(splitedArray[1]).intValue();
		
		if(x < y) {
			swap(x, y);
		}
		
		if(y == 0) {
			return 0;
		}
		
		while(x % y != 0) {
			int temp = x % y;
			x = y;
			y = temp;
		}
		
		return y;
	}

	private static void swap(int x, int y) {
		int temp = x;
		y = x;
		x = temp;
	}
}

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

int gcd(int a, int b) {
    if (b == 0) return a;
    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<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int gcd(int a, int b) {

    if(a < b)   swap(a, b);
    if(b == 0)  return a; 

    return gcd(a % b, b);
}

int main() {

    int a, b;
    while(cin >> a >> b) {

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

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
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 lcm( int m, int n ) {
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

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

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

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

int main()
{
    int a=0;b=0;
    while(cin >> a >> b){
    int c=0;

    if(a<b){
        swap(a,b);
    }
    while(b>0){
        c = a%b;
        a=b;
        b=c;
    }
    cout << a;
    cout << endl;
    }
}

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

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

C++: #include<iostream>
using namespace std;
int main(){
	long long x,y,i,j,k,c,s,d,gcd=0;
	while(cin>>x>>y){
		if(x==0&&y==0)
			cout<<"0"<<endl;
		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 <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 <algorithm>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define vint vector<int>

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

int main(){
    int a,b;
    while(~scanf("%d%d",&a,&b)) {
        cout << gcd(a,b) << endl;
    }

    return 0;
}

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

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

//left is greater
void swp(int* i, int* j){
  if(*i < *j){
    int tmp = *i;
    *i = *j;
    *j = tmp;
  }
}

int main(void){
  int n1, n2;
  while(cin >> n1 >> n2){
    swp(&n1, &n2);
    while(n2 > 0){
      n1 = n1 % n2;
      swap(n1, n2);
    }
    cout << n1 << endl;
  }
  return 0;
}

C++: using namespace std;

int main(void){
  int a,b,tmp;

  while(cin>>a>>b){
    if(a<b) swap(a,b);

    while(1){
      if(a%b==0) break;

      tmp = a%b;
      a = b;
      b = tmp;
    }
    cout<<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;
}//gcd
int main(){
  int m,n;
  while(cin>>m>>n) cout << gcd(m,n) << endl;
  return 0;
}

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

int GCD(int a,int b){
    int tmp;
    
    if(!(a >= b)){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    
    
    for(;;){
        if(!b) break;
        a %= b;
        tmp = a;
        a = b;
        b = tmp;
    }
    
    return a;
}

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

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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)

//repetition
//------------------------------------------
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T> ostream & operator<<(ostream& os, vector<T> const& v){
        for(auto it=v.begin(); it!=v.end(); ++it){
            os << *it << (it+1==v.end() ? "" : ",");
        }
        return os;
    }
}

//clear memory
#define clr(a) memset((a), 0 ,sizeof(a))
 
int lcm(int a,int b){
   return a*b/__gcd(a,b);
}
 
bool prime_number(int n){
   if(n==0||n==1) return false;
   vb a(n+1);
   fill(all(a),true);
   loop(i,2,n/2+1){
      if(!a[i]) continue;
      for(int j=2;i*j<=n;j++){
         a[i*j]=false;
      }
   }
   return a[n];
}

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