Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)
	for scanner.Scan() {
		table := [9][9]int{}
		check := [9][9]bool{}
		n, _ := strconv.Atoi(scanner.Text())
		for n > 0 {
			n--
			for i := 0; i < 9; i++ {
				for j := 0; j < 9; j++ {
					table[i][j] = nextInt()
				}
			}
			for i := 0; i < 9; i++ {
				for j := 0; j < 9; j++ {
					ok := true
					for k := 0; k < 9; k++ {
						if table[i][j] == table[i][k] && j != k {
							ok = false
						}
					}
					for k := 0; k < 9; k++ {
						if table[i][j] == table[k][j] && i != k {
							ok = false
						}
					}
					seci := i/3
					secj := j/3
					for k := 0; k < 3; k++ {
						for l := 0; l > 3; l++ {
							if table[seci*3+k][secj*3+l]==table[i][j]&&seci*3+k!=i&&secj*3+l!=j {
								ok = false
							}
						}
					}
					if !ok {
						check[i][j] = true
					}
				}
			}
			for i := 0; i < 9; i++ {
				for j := 0; j < 9; j++ {
					if check[i][j] {
						fmt.Print("*")
					} else {
						fmt.Print(" ")
					}
					fmt.Print(table[i][j])
				}
				fmt.Println()
			}
			if n != 0 {
				fmt.Println()
			}
		}
	}
}

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

Python: from __future__ import print_function
from sys import stdin, stdout

try:
    xrange
except NameError:
    pass
else:
    range = xrange

def solve():
    table = []
    for _ in range(9):
        table.append(stdin.readline().split())
    
    check_table = []
    for _ in range(9):
        check_table.append([False] * 9)
    
    # horizontal check
    for i in range(9):
        a = []
        for j in range(9):
            a.append(table[i][j])
        for j in range(9):
            n = table[i][j]
            if a.count(n) > 1:
                check_table[i][j] = True
    
    # vertical check
    for j in range(9):
        a = []
        for i in range(9):
            a.append(table[i][j])
        for i in range(9):
            n = table[i][j]
            if a.count(n) > 1:
                check_table[i][j] = True
    
    # 9x9 check
    for i in range(0, 9, 3):
        for j in range(0, 9, 3):
            a = []
            for di in range(3):
                for dj in range(3):
                    a.append(table[i + di][j + dj])
            for di in range(3):
                for dj in range(3):
                    n = table[i + di][j + dj]
                    if a.count(n) > 1:
                        check_table[i + di][j + dj] = True
    
    for i in range(9):
        for j in range(9):
            if check_table[i][j]:
                stdout.write('*')
            else:
                stdout.write(' ')
            stdout.write(table[i][j])
        stdout.write('\n')

if __name__ == '__main__':
    N = int(stdin.readline())
    for _ in range(N):
        solve()

Python: from __future__ import print_function
from sys import stdin, stdout

try:
    xrange
except NameError:
    pass
else:
    range = xrange

def solve():
    table = []
    for _ in range(9):
        table.append(stdin.readline().split())
    
    check_table = []
    for _ in range(9):
        check_table.append([False] * 9)
    
    # horizontal check
    for i in range(9):
        a = []
        for j in range(9):
            a.append(table[i][j])
        for j in range(9):
            n = table[i][j]
            if a.count(n) > 1:
                check_table[i][j] = True
    
    # vertical check
    for j in range(9):
        a = []
        for i in range(9):
            a.append(table[i][j])
        for i in range(9):
            n = table[i][j]
            if a.count(n) > 1:
                check_table[i][j] = True
    
    # 9x9 check
    for i in range(0, 9, 3):
        for j in range(0, 9, 3):
            a = []
            for di in range(3):
                for dj in range(3):
                    a.append(table[i + di][j + dj])
            for di in range(3):
                for dj in range(3):
                    n = table[i + di][j + dj]
                    if a.count(n) > 1:
                        check_table[i + di][j + dj] = True
    
    for i in range(9):
        for j in range(9):
            if check_table[i][j]:
                stdout.write('*')
            else:
                stdout.write(' ')
            stdout.write(table[i][j])
        stdout.write('\n')

if __name__ == '__main__':
    N = int(stdin.readline())
    for i in range(N):
        if i > 0:
            stdout.write('\n')
        solve()

Python: from collections import Counter

CounterKey = ("1", "2", "3", "4", "5", "6", "7", "8", "9")

inputCount = int(input())

for _ in range(inputCount):
    puzzle = []
    mark = []

    for lp in range(9):
        puzzle.append([item for item in input().split(" ")])
        mark.append([item for item in " " * 9])

    # 横
    for rowIndex, row in enumerate(puzzle):
        counter = Counter(row)
        needNum = [num for num in CounterKey if 1 < counter[num]]

        if not needNum:
            continue

        for colIndex, item in enumerate(row):
            if item in needNum:
                mark[rowIndex][colIndex] = "*"

    # 縦
    for colIndex, col in enumerate(
            zip(puzzle[0], puzzle[1], puzzle[2], puzzle[3], puzzle[4], puzzle[5], puzzle[6], puzzle[7], puzzle[8])):
        counter = Counter(col)
        needNum = [num for num in CounterKey if 1 < counter[num]]

        if not needNum:
            continue

        for rowIndex, item in enumerate(col):
            if item in needNum:
                mark[rowIndex][colIndex] = "*"

    # 四角
    for lp in range(3):
        block = []

        for blockCount, col in enumerate(zip(puzzle[lp * 3], puzzle[lp * 3 + 1], puzzle[lp * 3 + 2])):
            block.extend(col)

            if blockCount % 3 - 2 == 0:

                counter = Counter(block)
                needNum = [num for num in CounterKey if 1 < counter[num]]

                if needNum:

                    for index, item in enumerate(block):
                        if item in needNum:
                            rowIndex, colIndex = lp * 3 + index % 3, blockCount - 2 + index // 3
                            mark[rowIndex][colIndex] = "*"

                block = []

    # 出力
    for p, m in zip(puzzle, mark):
        output = []

        for num, state in zip(p, m):
            output.append(state)
            output.append(num)

        print("".join(output))

Python: n=int(input())
for i in range(n):
    board=[]
    check=[[0 for a in range(9)] for b in range(9)]
    for j in range(9):
        board.append(list(map(int,input().split())))
    board_r = [list(x) for x in zip(*board)]
    for j in range(9):
        for k in range(9):
            if board[j].count(board[j][k])>1:check[j][k]=1
    for j in range(9):
        for k in range(9):
            if board_r[j].count(board_r[j][k])>1:check[k][j]=1
    for j in range(3):
        for k in range(3):
            ch_list=[]
            for l in range(9):
                ch_list.append(board[j*3+l%3][k*3+l//3])
            for l in range(9):
                if ch_list.count(ch_list[l])>1:check[j*3+l%3][k*3+l//3]=1
    for j in range(9):
        for k in range(9):    
            if check[j][k]==1:print("*",end="")
            else:print(" ",end="")
            print(board[j][k],end="")
        print()
    if i<n-1:print()