Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

//Min .
func Min(a, b int) int {
	switch a < b {
	case true:
		return a
	default:
		return b
	}
}

//GCDandLCM .
func GCDandLCM(i []int) (int, int) {
	a := i[0]
	b := i[1]

	for {
		if a == b {
			break
		} else {
			a, b = Min(a, b), int(math.Abs(float64(a-b)))
		}
	}

	return a, i[0] * i[1] / a
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()
		g, _ := GCDandLCM(i)
		fmt.Println(g)
	}

}

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

int main(){
	long long int a,b,c;
	while(cin >> a >> b){
		if(a != 0 && b != 0)while(1){
			if(a<b){
				c = b%a;
			}
			else {
				c = a%b;
			}
			if(c!=0){
				a = b;
				b = c;
			}
			else {
				break;
			}
		}
		if(a != 0 && b != 0){
			cout << b << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	return 0;
}

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

int euklides(int a, int b) {
    while (a % b!= 0) {
        int tmp = b;
        b = a % b;
        a = tmp;
    }
    return b;
}

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

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

using namespace std;

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

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

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

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

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

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

C++: #include <stdio.h>

int main(){
int x,y;

int byakko(int x, inty){
x > y ? return x % y : return y % x;
}

while(scanf("%d %d", &x, &y)){
cout << byakko(x, y) << endl;
}
}

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

int Egcd(int x, int y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return Egcd(y, x % y);
}

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

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

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

int main(){
    int x, y;
    while(cin >> x >> y){
        cout << gcd(x, y) << endl;
    }
}

C++: #include <iostream>

using namespace std;
int main(){
	int a,b,ret;
	while(cin>>a>>b, !cin.eof()){
		if(a==0 || b==0) ret = 0;
		else if(a>=b){
			while(b!=0){
				ret = b;
				b = a%b;
				a = ret;
			}
			ret = a;
		}else{
			while(a!=0){
				ret = a;
				a = a%b;
				b = ret;
			}
			ret = b;
		}
		cout<<ret<<endl;
	}
}

C++: #include<bits/stdc++.h>
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)swap(a,b);
    cout << gcd(a,b)<<endl;
  }
  return 0;
}

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

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

int main(){
	long long int a,b,c;
	while(cin >> a >> b){
		while(1){
			if(a<b){
				c = b%a;
			}
			else {
				c = a%b;
			}
			if(c!=0){
				a = b;
				b = c;
			}
			else {
				break;
			}
		}
		cout << b <<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}


int main(){
    int a,b;
    while (cin >> a >> b){
        //cin >> a >> b;
        cout << GCD(max(a,b),min(a,b)) << endl;
    }
}

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 <iostream>

using namespace std;

int gcd(int a,int b) {

  if(b==0) return a;

  else return gcd(b,a%b);

}

int main() {

  int a,b;

  while(cin >> a >> b) {

    cout << gcd(a,b) << endl;

  }

  return 0;

}

C++: #include <iostream>

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


int main()
{
	int m,n;
	
	while( std::cin >> m >> n, (m||n) )
	{

		if( m >= n )
			std::cout << eucgcd(m, n) << std::endl;
		else
			std::cout << eucgcd(n, m) << std::endl;
			
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <string.h>

long int gcd(long int a, long int b)
{
return (b==0 ? a : gcd (b, a%b));
}
int main()
{
    long long a, b;
    while(scanf ("%lld %lld", &a, &b) != EOF)
    {
              long long x = gcd(a,b);
              printf("%d\n", x);
    }
return 0;
}

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

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

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

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;



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

    
    return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double EPS = 1e-8;

int tx[] = {1,0};
int ty[] = {0,1};

ll GCD(ll a ,ll b){
	return b > 0 ? GCD(b,a%b) : a;
}

int main(){
	int a,b;
	while(~scanf("%d %d",&a,&b)){
		printf("%lld\n",GCD(a,b));
	}
}