import java.util.Arrays;
import java.util.Scanner;

class Sudoku {
	private final int SIZE = 9;
	private final int[] MASK = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
	private int[] row, col, group;
	private int[][] map;
	private int blank;
	private boolean solved;
	private int count;
	
	private void solve() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String[] data = new String[SIZE];
			for(int i=0;i<SIZE;i++) {
				data[i] = sc.nextLine();
			}
			
			solved = false;
			blank = 0;
			count = 0;
			row = new int[SIZE];
			col = new int[SIZE];
			group = new int[SIZE];
			map = new int[SIZE][SIZE];
			Arrays.fill(row, 0);
			Arrays.fill(col, 0);
			Arrays.fill(group, 0);
			for(int i=0;i<SIZE;i++) {
				for(int j=0;j<SIZE;j++) {
					map[i][j] = data[i].charAt(j)-'0';
					if(map[i][j]==0) {
						blank++;
					} else {
						setBit(j, i, map[i][j]);
					}
				}
			}
			find(0, 0);
			if(!solved) {
				System.out.println("先生…解けません…！");
			}
		}
	}
	
	private void find(int x, int y) {
		if(count==blank) {
			put(map);
			solved = true;
		} else {
			while(map[y][x]!=0) {
				if(x+1==SIZE) y = (y + 1) % SIZE;
				x = (x + 1) % SIZE;
			}
			for(int i=1;i<=9;i++) {
				if(!testBit(x, y, i)) {
					setBit(x, y, i);
					map[y][x] = i;
					count++;
					find(x, y);
					if(solved) return;
					count--;
					map[y][x] = 0;
					clearBit(x, y, i);
				}
			}
		}
	}
	
	private void setBit(int x, int y, int n) {
		row[y] |= MASK[n];
		col[x] |= MASK[n];
		group[getGroup(x, y)] |= MASK[n];
	}
	
	private void clearBit(int x, int y, int n) {
		row[y] &= ~MASK[n];
		col[x] &= ~MASK[n];
		group[getGroup(x, y)] &= ~MASK[n];
	}
	
	private boolean testBit(int x, int y, int n) {
		return ((row[y] & MASK[n]) > 0) || ((col[x] & MASK[n]) > 0) || ((group[getGroup(x, y)] & MASK[n]) > 0);
	}
	
	private int getGroup(int x, int y) {
		return (y / 3) * 3 + (x / 3);
	}
	
	private void put(int[][] map) {
		for(int i=0;i<SIZE;i++) {
			for(int j=0;j<SIZE;j++) {
				System.out.printf("%d", map[i][j]);
			}
			System.out.println();
		}
		System.out.println();
	}
		
	public static void main(String[] args) { 
		new Sudoku().solve();
	}
}