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>
using namespace std;

int a, b;

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

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

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

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

    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n1,n2,minv,maxv,i;
  while(cin >> n1){
    cin >> n2;
    minv=min(n1,n2);
    maxv=1;
    for(i=1;i<=minv;i++){
      if(n1%i==0&&n2%i==0) maxv=max(maxv,i);
    }
    cout << maxv << endl;
  }
  return 0;
}

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

int main() {
  for (int a, b; cin >> a >> b; ) {
    if (a == 0 && b == 0) break;
    cout << __gcd(a, b) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

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

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int kaizyo(int x){
    if(x==1)return x;
    else return x*kaizyo(x-1);
}


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

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

int main(){
	int a,b,c;
	while(cin >> a){
		cin >> b;
		while(1){
			if(b>a){
				c=b;b=a;a=c;
			}
			a=a%b;
			if(a==0){
				break;
			}
		}
		cout << b <<"\n";
	}
		
	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

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

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

C++: #include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll gcd2(ll a,ll b){
	while(b!=0){
		ll w=a%b;
		a=b;
		b=w;
	}
	return a;
}
int main(){
	int m,n;
	while(cin>>m>>n) cout<<gcd2(m,n)<<"\n";
	return 0;
}

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

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

using namespace std;

int main()
{
	int a, b;

	while (scanf("%d%d", &a, &b) != EOF){
		int ma = max(a, b);
		int mi = min(a, b);
		int rem;

		while (1){
			rem = ma % mi;
			if (rem == 0){
				break;
			}
			ma = mi;
			mi = rem;
		}
		cout << mi << endl;
	}

	return (0);
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  while(cin>>n>>m){
    cout<<__gcd(n,m)<<endl;
  }
}

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

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

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

using namespace std;

void change(int *, int *);

int main(void)
{
	int x, y;
	
	while(scanf("%d %d", &x, &y) != EOF){
		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<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;

int main() {

	int a, b;
	int gcd;
	int i;
	while (cin >> a >> b) {
		gcd = 1;
		i = 2;
		while (i <= a && i <= b) {
			if (a % i == 0 && b % i == 0) {
				gcd *= i;
				a /= i;
				b /= i;

			}
			else i++;
		}
		printf("%d\n", gcd);


	}
	//system("pause");
	return 0;
}

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

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

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

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

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

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979

int g(int x,int y){
	int a=max(x,y),b=min(x,y);
	if(a%b==0) return b;
	else return g(b,a%b);
}

int main(void){

	int x,y;
	while(cin >> x >> y){

		cout << g(x,y) << endl;

	}

	return 0;
}