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 <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

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

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

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

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

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

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

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

C++: #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int a, b;
    while (cin >> a >> b){
      while (a != b){
		  a > b ? a -= b : b -= a;  
		}
	cout << a << endl;
   }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}

C++: #include <bits/stdc++.h>
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;
	}
}

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

using namespace std;

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

int main() {
  int a, b;
  while (scanf("%d%d", &a, &b) == 2) {
    if (a < b) swap(a, b);
    printf("%d\n", gcd(a, b));
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
using namespace std;
int main(){
    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!=0?gcd(b,a%b):a;
}
int main() {
	int a, b;
	while (scanf("%d%d",&a,&b)!=EOF) printf("%d\n",gcd(a,b));
}

C++: #include <iostream>

int eucgcd(int m, int n)
{
	int p = m%n;
	
	while( p > 0 )
	{
		m = n;
		n = p;
		p = m%n;
	}
	
	return n;
}


int main()
{
	int m,n;
	
	while( std::cin >> m >> n, (m != EOF && n != EOF) )
	{
		if( m >= n )
			std::cout << eucgcd(m, n) << std::endl;
		else
			std::cout << eucgcd(n, m) << std::endl;
	}
	
	
	return 0;
}

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

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    while (cin>>a>>b) {
        while (a%b!=0) {
            int tmp=b;
            b=a%b;
            a=tmp;
        }
        cout<<b<<endl;
    }
}

C++: ??????

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

int main(){
    int x,y;
    
    while(cin >> x >> y){
        int tmp;
        
        if(x < y){
            tmp = x;
            x = y;
            y = tmp;
        }
        
        while(y){
            x %= y; tmp = x;
            x = y; y = tmp;
        }
        cout << x << endl;
    }
    
    return 0;
}

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

int main(){
	int x,y;
	while(cin >> x >> y){
		if(x < y){
			x^=y;
			y^=x;
			x^=y;
		}
		while(y){
			x %= y;
			if(x < y){
				x^=y;
				y^=x;
				x^=y;
			}
		}
		cout << x << endl;
	}
}

C++: main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",__gcd(a,b));}

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

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

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

    return 0;
}

C++: #include <iostream>

int main(){

int x,y;

cin >> x >> y;

while(x != y){
if(x > y)x = x - y;
if(y > x)y = y - x;
}
cout << x;
}

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

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

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

C++: #include <stdio.h>

int main(void)
{
	int x, y;
	int a, b;
	int tmp;
	
	while (scanf("%d %d", &x, &y) != EOF){
		a = x;
		b = y;
		while (a % b != 0){
			tmp = a % b;
			a = b;
			b = tmp;
		}
		printf("%d\n", b);
	}
	return (0);
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int a,b;

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

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int a, b;

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

	return gcd(b, a%b);
}

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

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

C++: #include "stdio.h"

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

int main()
{
	int p,q;
	scanf("%d%d",&q,&p);
	printf("%d",g(q,p));
}