Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	table := [9][9]int{}
	check := [9][9]bool{}
	n, _ := strconv.Atoi(scanner.Text())
	for n > 0 {
		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()
		}
		n--
	}
}

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

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto& e:c)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)

ll const inf = 1<<28;
double const pi = acos(-1);

int g[9][9];
bool ok[9][9];

void solve(){
    rep(y,9)rep(x,9){
        if(!ok[y][x]) continue;
        loop(i,y+1,9){
            if(g[y][x]==g[i][x]){
                ok[i][x]=false;
                ok[y][x]=false;
            }
        }

        loop(j,x+1,9){
            if(g[y][x]==g[y][j]){
                ok[y][j]=false;
                ok[y][x]=false;
            }
        }
    }

    rep(i,3)rep(j,3){
        rep(a,9){
            int x=a%3+i*3;
            int y=a/3+j*3;
            loop(b,a+1,9){
                int xx=b%3+i*3;
                int yy=b/3+j*3;
                if(g[y][x]==g[yy][xx]){
                    ok[yy][xx]=false;
                    ok[y][x]=false;
                }
            }
        }
    }
}

int main(){
    int n;
    cin>>n;
    rep(i,n){
        rep(y,9)rep(x,9){
            ok[y][x]=true;
        }
        rep(i,9)rep(j,9)cin>>g[i][j];
        solve();
        rep(y,9)rep(x,9){
            printf("%c%d",ok[y][x]?' ':'*',g[y][x]);
            if(x+1==9)puts("");
        }
        if(i+1!=n)puts("");
    }
}

C++: #include<iostream>
#include<cstring>

using namespace std;

int main(void) {
	int num;
	int map[9][9], check[10];
	bool mapb[9][9];
	int i, j, k;

	cin >> num;

	for(i = 0; i < num; i++) {
		for(j = 0; j < 9; j++) {
			for(k = 0; k < 9; k++) {
				cin >> map[j][k];
				mapb[j][k] = false;
			}
		}

		for(j = 0; j < 9; j++) {
			memset(check, 0, sizeof(check));
			for(k = 0; k < 9; k++) {
				check[map[j][k]]++;
			}
			for(k = 0; k < 9; k++) {
				if(check[map[j][k]] >= 2) { mapb[j][k] = true; }
			}
		}

		for(j = 0; j < 9; j++) {
			memset(check, 0, sizeof(check));
			for(k = 0; k < 9; k++) {
				check[map[k][j]]++;
			}
			for(k = 0; k < 9; k++) {
				if(check[map[k][j]] >= 2) { mapb[k][j] = true; }
			}
		}

		for(j = 0; j < 9; j++) {
			memset(check, 0, sizeof(check));
			for(k = 0; k < 9; k++) {
				check[map[k/3+(j/3)*3][k%3+(j%3)*3]]++;
			}
			for(k = 0; k < 9; k++) {
				if(check[map[k/3+(j/3)*3][k%3+(j%3)*3]] >= 2) { mapb[k/3+(j/3)*3][k%3+(j%3)*3] = true; }
			}
		}

		for(j = 0; j < 9; j++) {
			for(k = 0; k < 9; k++) {
				cout << (mapb[j][k]?"*":" ") << map[j][k];
			}
			cout << endl;
		}

		if(i+1 < num) { cout << endl; }
	}
	return 0;
}

C++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

int field[9][9];
const int p[] = {0, 3, 6};

char check(int y, int x)
{
  REPS(i, x, 9) if (x != i && field[y][x] == field[y][i]) return '*';
  REPS(i, y, 9) if (y != i && field[y][x] == field[i][x]) return '*';
  DEP(i, x) if (x != i && field[y][x] == field[y][i]) return '*';
  DEP(i, y) if (y != i && field[y][x] == field[i][x]) return '*';

  REPS(i, p[y / 3], p[y / 3] + 3){
    REPS(j, p[x / 3], p[x / 3] + 3){
      if (i == y && j == x) continue;
      if (field[y][x] == field[i][j]) return '*';
    }
  }

  return ' ';
}

signed main()
{
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int n;
  scanf("%d", &n);

  while (n--){
    char table[9][9];
        
    REP(i, 9) REP(j, 9) scanf("%d", &field[i][j]);
    
    REP(i, 9){
      REP(j, 9){
        table[i][j] = check(i, j);
      }
    }
    REP(i, 9){
      REP(j, 9){
        printf("%c%d", table[i][j], field[i][j]);
      }
      puts("");
    }
    if (n != 0) puts("");
  }

  return (0);
}