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
}

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(i,9)rep(j,9){
            printf("%c%d",ok[i][j]?' ':'*',g[i][j]);
            if(j+1==9)puts("");
        }
        if(i+1!=n)puts("");
    }
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-3;
const double PI = acos(-1);

int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int d[9][9];
bool f[9][9];

vector<pii> v(9);

void input(){
	rep(i, 9) rep(j, 9) cin>>d[i][j], f[i][j] = false;
}
void output(){
	for(int i = 0; i < 9; i++){
		for(int j = 0; j < 9; j++){
			printf("%c%d", f[i][j]?'*':' ', d[i][j]);
		}
		printf("\n");
	}
}
void calc(){
	for(int i = 0; i < 8; i++){
		for(int j = i + 1; j < 9; j++){
			if(v[i].fi == v[j].fi){
				f[v[i].se/10][v[i].se%10] = true;
				f[v[j].se/10][v[j].se%10] = true;
			}
		}
	}
}

int main(){
	int n;
	cin>>n;
	rep(Case, n){
		if(Case != 0) printf("\n");
		input();
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				v[j] = mp(d[i][j], i*10+j);
			}
			calc();
		}
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				v[j] = mp(d[j][i], j*10+i);
			}
			calc();
		}
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 3; k++){
					for(int l = 0; l < 3; l++){
						int y = i * 3 + k, x = j * 3 + l, idx = k * 3 + l;
						v[idx] = mp(d[y][x], y* 10 + x);
					}
				}
				calc();
			}
		}
		output();
	}
}

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

const int COL_SIZE = 9;
const int ROW_SIZE = 9;

void inputBoard( int board[][ COL_SIZE ] )
{
	for( int i = 0; i < ROW_SIZE; ++i ){
		for( int j = 0; j < COL_SIZE; ++j ){
			cin >> board[ i ][ j ];
		}
	}
}

void outputBoard( int board[][ COL_SIZE ], bool check[][ COL_SIZE ] )
{
	for( int i = 0; i < ROW_SIZE; ++i ){
		for( int j = 0; j < COL_SIZE; ++j ){
			cout << ( check[ i ][ j ] ? '*' : ' ' ) << board[ i ][ j ];
		}
		cout << endl;
	}
}

enum{
	COL = 0,
	ROW,
	BLOCK
};

bool investigate( int board[][ COL_SIZE ], bool check[][ COL_SIZE ] )
{
	for( int i = 0; i < ROW_SIZE; ++i ){
		int usedNumber[ 3 ][ 10 ];
		memset( usedNumber, 0, sizeof(usedNumber) );
		for( int j = 0; j < COL_SIZE; ++j ){
			usedNumber[ COL ][ board[ i ][ j ] ]++;
			usedNumber[ ROW ][ board[ j ][ i ] ]++;
			usedNumber[ BLOCK ][ board[ ( i / 3 ) * 3 + j / 3 ][ ( i % 3 ) * 3 + j % 3 ] ]++;
		}
		for( int j = 0; j < COL_SIZE; ++j ){
			if( usedNumber[ COL ][ board[ i ][ j ] ] > 1 ){
				check[ i ][ j ] = true;
			}
			if( usedNumber[ ROW ][ board[ j ][ i ] ] > 1 ){
				check[ j ][ i ] = true;
			}
			int y = ( i / 3 ) * 3 + j / 3;
			int x = ( i % 3 ) * 3 + j % 3;
			if( usedNumber[ BLOCK][ board[ y ][ x ] ] > 1 ){
				check[ y ][ x ] = true;
			}
		}
	}
	return false;
}

int main()
{
	int n;
	cin >> n;
	for( int i = 0; i < n; ++i ){
		int board[ ROW_SIZE ][ COL_SIZE ];
		bool check[ ROW_SIZE ][ COL_SIZE ];
		memset( check, 0, sizeof(check) );
		inputBoard( board );
		investigate( board, check );
		if( i != 0 ){
			cout << endl;
		}
		outputBoard( board, check );
	}
	return 0;
}