Go: package main

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

func gcd(num1, num2 int) int {
	if num2 == 0 {
		return num1
	}
	num3 := num1 % num2
	return gcd(num2, num3)
}

func lcm(num1, num2 int) int {
	if num1%num2 != 0 {
		num3 := gcd(num1, num2)
		for i := 1; ; i++ {
			check := num3 * i
			if check%num1 == 0 && check%num2 == 0 {
				return check
			}
		}
	} else {
		return num1
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		row := strings.Fields(scanner.Text())
		nums := []int{}

		for _, v := range row {
			num, _ := strconv.Atoi(v)
			nums = append(nums, num)
		}
		fmt.Println(gcd(nums[0], nums[1]), lcm(nums[0], nums[1]))
	}
}

C++: /*************************************************************************
    > File Name: aoj0005.cpp
    > Author:    WArobot 
    > Blog:      http://www.cnblogs.com/WArobot/ 
    > Created Time: 2017??´06???19??\ ????????? 16??¶44???39?§?
 ************************************************************************/

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

#define ll long long
ll gcd(ll a,ll b){
	return b == 0 ? a : gcd(b,a%b);
}
int main(){
	ll a , b;
	while(~scanf("%lld%lld",&a,&b)){
		ll ret = gcd(a,b);
		printf("%lld %lld\n",ret,a*b/ret);
	}
	return 0;
}

C++: #include <algorithm>
#include <iostream>
int main() {
	long long a, b;
	while (std::cin >> a >> b) {
		std::cout << __gcd(a,b) << " " << a / __gcd(a,b) * b << "\n";
	}
}

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

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

int main() {
    int a,b;
    while (cin>>a>>b) {
        if (a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }

        int gcd = get_gcd(a,b);

        int lcm = a / gcd * b;
        cout << gcd << " " << lcm << endl;

    }
    return 0;
}

C++: #include<cstdio>
int a,b;int g(int a,int b){return b?g(b,a%b):a;}main(){while(~scanf("%d%d",&a,&b))printf("%d %d\n",g(a,b),a/g(a,b)*b);}

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

using namespace std;

int main() {
    int a,b,a2,b2;
    int lcm,gcd;
    while(cin >> a >> b){
        a2=a;
        b2=b;
        while(a != b){
        if(a>b){a = a-b;}
        else{b=b-a;}
        }
        lcm = a;
        gcd=a2 / lcm * b2;
        cout << lcm << " " << gcd << endl;
    }

}

C++: /*#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <set>
#include <utility>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    return 0;
}
*/
/*
DLX解决9*9的数独??，?化?729*324的精?覆盖??
行：
一共9 * 9 * 9 == 729行。一共9 * 9小格，?一格有9?可能性(1 - 9)，?一?可能都??着一行。
列：
一共(9 + 9 + 9) * 9 + 81 == 324 ?前面三个9分?代表着9行9列和9小?，乘以9的意思是9?可能(1 - 9)，因???可能只可以??一个。
81代表着81个小格，限制着?一个小格只放一个数字。
?入数据后，如果?'.'，?建9行，即有1-9?可能，否?建一行，表示某小格只能放?定的某个数字。
*/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int INF = 0x7fffffff;
const int NN = 350;
const int MM = 750;
#define N 9
int n,m;    //列，行
int cntc[NN];
int L[NN*MM],R[NN*MM],U[NN*MM],D[NN*MM];//?点的左?，右?，上?，下?
int C[NN*MM];
int head;
int mx[MM][NN];
int O[MM],idx;
int ans[10][10];

//?除列及其相?的行
void remove(int c)
{
    int i,j;
    L[R[c]] = L[c];
    R[L[c]] = R[c];
    for(i = D[c]; i != c; i = D[i])
    {
        for(j = R[i]; j != i; j = R[j])
        {
            U[D[j]] = U[j];
            D[U[j]] = D[j];
            cntc[C[j]]--;
        }
    }
}

//恢?列及其相?的行
void resume(int c)
{
    int i,j;
    R[L[c]] = c;
    L[R[c]] = c;
    for(i = D[c]; i != c; i = D[i])
    {
        for(j = R[i]; j != i; j = R[j])
        {
            U[D[j]] = j;
            D[U[j]] = j;
            cntc[C[j]]++;
        }
    }
}

bool dfs()
{
    int i,j,c;
    if(R[head] == head)
        return true;
    int min = INF;
    for(i = R[head]; i != head; i = R[i])
    {
        if(cntc[i] < min)
        {
            min = cntc[i];
            c = i;
        }
    }
    remove(c);
    for(i = D[c]; i != c; i = D[i])
    {
        //i是某点的序号，将?点所在行的行号保存
        O[idx++] = (i-1)/n;
        for(j = R[i]; j != i; j = R[j])
            remove(C[j]);
        if(dfs())
            return true;
        for(j = L[i]; j != i; j = L[j])
            resume(C[j]);
        idx--;
    }
    resume(c);
    return false;
}

bool build()
{
    int i,j,now,pre,first;
    idx = head = 0;
    for(i = 0; i < n; i++)
    {
        R[i] = i+1;
        L[i+1] = i;
    }
    R[n] = 0;
    L[0] = n;
    //列双向?表
    for(j = 1; j <= n; j++)
    {
        pre = j;
        cntc[j] = 0;
        for(i = 1; i <= m; i++)
        {
            if(mx[i][j])
            {
                cntc[j]++;//j的?数
                now = i*n+j;
                C[now] = j;//C?列指?
                D[pre] = now;
                U[now] = pre;
                pre = now;
            }
        }
        U[j] = pre;
        D[pre] = j;
        if(cntc[j] == 0)
            return false;
    }
    //行双向?表
    for(i = 1; i <= m; i++)
    {
        pre = first = -1;
        for(j = 1; j <= n; j++)
        {
            if(mx[i][j])
            {
                now = i*n+j;
                if(pre == -1)
                    first = now;
                else
                {
                    R[pre] = now;
                    L[now] = pre;
                }
                pre = now;
            }
        }
        if(first != -1)
        {
            R[pre] = first;
            L[first] = pre;
        }
    }
    return true;
}

int T;

void print()
{
    int i,j;
    int x,y,k;
    for(i = 0; i < idx; i++)
    {
        int r = O[i];
        k = r%9;
        if(k==0) k = 9;
        int num = (r - k)/9 + 1;
        y = num%9;
        if(y == 0) y = 9;
        x = (num-y)/9 + 1;
        ans[x][y] = k;
    }
    if(idx == 0)
        printf("impossible\n");
    else
    {
        for(i = 1; i <= 9; i++)
        {
            for(j = 1; j <= 9; j++)
                printf("%d",ans[i][j]);
        }
        cout<<endl;
    }
}

int map[MM][NN];
string str;
void readdata()
{
    char ch;
    int ind=0;
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= N; j++)
          {
            ch=str[ind++];
            if(ch=='.')
            map[i][j]=0;
            else
            map[i][j]=ch-'0';
          }
}
int main()
{
    //freopen("input.txt","r",stdin);
    int i,j,k;
    int cases;
    char cao[12];
    char s[12][12];
    while(1)
    {
        cin>>str;
        if(str=="end")break;
        memset(mx,0,sizeof(mx));
        readdata();
        for(i = 1; i <= 9; i++)
        {
            for(j = 1; j <= 9; j++)
             {
                int t = (i-1)*9 + j;
                if(map[i][j] == 0)
                {
                    for(k = 1; k <= 9; k++)
                    {
                        mx[9*(t-1)+k][t] = 1;               //81grid ?个小格只能放一个数字
                        mx[9*(t-1)+k][81+(i-1)*9+k] = 1;    //9row ?行数字k只能出?一次
                        mx[9*(t-1)+k][162+(j-1)*9+k] = 1;   //9col  ?列数字k只能出?一次
                        mx[9*(t-1)+k][243+((i-1)/3*3+(j+2)/3-1)*9+k] = 1;   //subgrid ?个3*3格子数字k只能出?一次
                    }
                }
                else
                {
                    k = map[i][j];
                    mx[9*(t-1)+k][t] = 1;               //81grid
                    mx[9*(t-1)+k][81+(i-1)*9+k] = 1;    //9row
                    mx[9*(t-1)+k][162+(j-1)*9+k] = 1;   //9col
                    mx[9*(t-1)+k][243+((i-1)/3*3+(j+2)/3-1)*9+k] = 1;   //subgrid
                }
            }
        }
        n = 324;
        m = 729;
        build();
        dfs();
        print();
    }
    return 0;
}