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++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int board[10][10];
int main(){
	cin>>n;
	for(int k = 0;k< n;k++){
		bool flag[10][10];
		rep(i,10){
			rep(j,10){
				flag[i][j] = true;
			}
		}
		for(int y = 1;y <=9;y++){
			for(int x = 1;x <=9;x++){
				cin>>board[y][x];
			}
		}
		for(int y = 1; y<=9;y+=3){//3×3ブロックごとの判定
			for(int x = 1;x <=9;x+=3){
				int cnt[10]={0};
				rep(i,3){
					rep(j,3){
						cnt[board[y+i][x+j]]+=1;
					}
				}
				rep(i,3){
					rep(j,3){
						if(cnt[board[y+i][x+j]]!=1){
							flag[y+i][x+j] =false;
						}
					}
				}
			}
		}
		for(int y = 1;y <=9;y++){//横の判定
			int cnt[10]={0};
			for(int x = 1;x <=9;x++){
				cnt[board[y][x]]+=1;
			}
			for(int x = 1; x<=9;x++){
				if(cnt[board[y][x]]!=1){
					flag[y][x] =false;
				}
			}
		}
		for(int x = 1;x <=9;x++){
			int cnt[10]={0};
			for(int y =1;y <=9;y++){
				cnt[board[y][x]]++;
			}
			for(int y = 1;y <=9;y++){
				if(cnt[board[y][x]]!=1){
					flag[y][x] = false;
				}
			}
		}
		for(int i = 1;i <=9;i++){
			for(int j = 1;j <=9;j++){
				printf("%c%d",(flag[i][j]?' ':'*'),board[i][j]);
			}
			cout<<endl;
		}
	}
	return 0;
}

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

#define N 9

void set(int *array,int n)
{
  for(int i=0;i<10;i++) *(array + i)=n;
}

int main()
{
  int n,i,j,mass[N][N],count[10];
  bool flag[N][N];
  cin>>n;
  while(n-->0){
    for(i=0;i<N;i++)for(j=0;j<N;j++){
      cin>>mass[i][j];
      flag[i][j]=0;
    }
    for(i=0;i<N;i++){
      set(count,0);
      for(j=0;j<N;j++)count[mass[i][j]]++;
      for(j=0;j<N;j++)if(count[mass[i][j]]>=2)flag[i][j]=true;
      set(count,0);
      for(j=0;j<N;j++)count[mass[j][i]]++;
      for(j=0;j<N;j++)if(count[mass[j][i]]>=2)flag[j][i]=true;
      set(count,0);
      int y=(i/3)*3;
      int x=(i%3)*3;
      for(j=0;j<N;j++)count[mass[y+j/3][x+j%3]]++;
      for(j=0;j<N;j++)if(count[mass[y+j/3][x+j%3]]>=2)flag[y+j/3][x+j%3]=true;
    }
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
	putchar(flag[i][j]?'*':' ');
	cout<<mass[i][j];
      }
      cout<<endl;
    }
    if(n>0)cout<<endl;
  }
}

C++: 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
template <class _Tv> inline string join(_Tv &v,string sep=" "){
    ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,_Tv _c,bool _p=false){
    ITER(_c) _it=_c.begin();
    if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

void solve(vector<vector<int> > &v){
    vector<vector<int> > f;
    f.resize(9,vector<int>(9));
    map<int,int> mx, my, mb;
    REP(i,9){
        mx.clear();my.clear();mb.clear();
        REP(j,9){
            mx[v[i][j]]++;
            my[v[j][i]]++;
        }
        REP(j,9){
            if(mx[v[i][j]] > 1) f[i][j] = true;
            if(my[v[j][i]] > 1) f[j][i] = true;
        }
        int by = i/3*3, bx = i%3*3;
        REP(k,3) REP(l,3){
            mb[v[by+k][bx+l]]++;
        }
        REP(k,3) REP(l,3){
            if(mb[v[by+k][bx+l]] > 1) f[by+k][bx+l] = true;
        }

    }
    REP(i,9){
        REP(j,9){
            printf("%c%d ", f[i][j]?'*':' ', v[i][j]);
        }
        printf("\n");
    }

}

int main(){
    int n;
    cin >> n;
    bool f = false;
    REP(i,n){
        vector<vector<int> > v;
        v.resize(9);
        REP(y,9){
            v[y].resize(9);
            REP(x,9){
                cin >> v[y][x];
            }
        }
        if(f) cout << endl;
        solve(v);
        f = true;
    }
    return 0;
}