package main

import (
	"fmt"
)

func main() {
	var maze [10][10]int
	for i := 0; i < 9; i++ {
		for j := 0; j < 9; j++ {
			fmt.Scan(&maze[i][j])
		}
	}
	var do func(x, y int) bool
	do = func(x, y int) bool {
		if maze[x][y] == 0 {
			xx := make(map[int]struct{}, 0)
			yy := make(map[int]struct{}, 0)
            block := make(map[int]struct{}, 0)
			for i := 0; i < 9; i++ {
				xx[maze[i][y]] = struct{}{}
				yy[maze[x][i]] = struct{}{}
			}
            for i := 0; i< 3; i++ {
                for j := 0; j < 3; j++ {
                    block[maze[x/3*3 + i][y/3*3+j]] = struct{}{}
                }
            }
			for i := 1; i < 10; i++ {
				_, ok1 := xx[i]
				_, ok2 := yy[i]
                _, ok3 := block[i]
				if !ok1 && !ok2 && !ok3{
					maze[x][y] = i
					if y+1 < 9 {
						if do(x, y+1) {
							return true
						}
					} else if x+1 < 9 {
						if do(x+1, 0) {
							return true
						}
					} else {
                        return true
                    }
                    maze[x][y] = 0
				}
			}
		} else {
			if y+1 < 9 {
				if do(x, y+1) {
					return true
				}
			} else if x+1 < 9 {
				if do(x+1, 0) {
					return true
				}
			} else {
                return true
            }
		}
        return false
	}
    do(0, 0)
    for i := 0; i < 9; i++ {
        for j := 0; j < 9; j++ {
            fmt.Printf("%d", maze[i][j])
            if j < 8 {
                fmt.Printf(" ")
            } else {
                fmt.Println("")
            }
        }
    }
}