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>
#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));
}

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

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

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

	return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());

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


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

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

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

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

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

int gcd(int m, int n);

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

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

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

int main()
{
  int a, b;

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

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

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

int main(void){
  unsigned int a,b;
  while(scanf("%u %u",&a,&b)!=0) cout<<euclid(a,b)<<endl;
  return 0;
}

C++: #include<iostream>
 
using namespace std;
 
int GCD(int M, int N) {
     
    while(N != 0) { 
        int r = M % N; 
        M = N; 
        N = r; 
    } 
    return M;
}
 
int main() { 
    int m, n; 
 
    while(cin >> m >> n) {
 
    cout << GCD(m, n) << "\n"; 

}
     
    return 0; 
}

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

using namespace std;

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);

	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>
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++: #include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

int gcd(int x, int y){
	return y ? gcd(y,x%y) : x;
}
int main(){
	int a,b;
	while(~scanf("%d%d",&a,&b)){
		printf("%d\n",gcd(a,b));
	}
	return 0;
}

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

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 <cstdio>
#include <algorithm>
using namespace std;
int a,b;
int main(){
  while(scanf("%d %d",&a,&b)!=EOF){
    for(int i=min(a,b);i>0;i--){
      if(a%i==0 && b%i==0){
        printf("%d\n",i);
        break;
      }
    }
  }
return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

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

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

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

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

int gcm(int a, int b)
{
  if (a > b)
  {
    int tmp = a;
    a = b;
    b = tmp;
    cerr << 'a' << endl;
  }

  for (int i = 1; ; ++i)
  {
    if (a % i == 0 and b % (a / i) == 0 )
    {
      return a / i;
    }
  }
}

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

  return 0;
}