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 {
		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++: #include <bits/stdc++.h>
using namespace std;

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

// rep
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

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

//////////////////////////////////////////////////////////////


int main() {
  
  int N;
  bool blank = 0;
  cin >> N;
  rep(_, N) {
    if(blank) cout << endl;
    blank = 1;
    int arr[9][9] = {{}};
    char output[9][20] = {{}};
    VII star;
    for(int i=0; i<9; i++) {
      int used[10] = {};
      for(int j=0; j<9; j++) {
	cin >> arr[i][j];
	used[arr[i][j]] ++;
	output[i][2*j]   = ' ';
	output[i][2*j+1] = (char)('0' + arr[i][j]);
      }
      for(int j=0; j<9; j++){
	if(used[arr[i][j]] > 1) {
	  output[i][2*j] = '*';
	}
      }
    }
    
    for(int j=0; j<9; j++) {
      int used[10] = {};
      for(int i=0; i<9; i++) {
	used[arr[i][j]] ++;
      }
      for(int i=0; i<9; i++) {
	if(used[arr[i][j]] > 1) {
	  output[i][2*j] = '*';
	}
      }
    }
    
    for(int i=0; i<3; i++) {
      for(int j=0; j<3; j++) {
	int used[10] = {};
	
	for(int k=0; k<3; k++) {
	  for(int l=0; l<3; l++) {
	    used[arr[i*3+k][j*3+l]] ++;
	  }
	}
	
	for(int k=0; k<3; k++) {
	  for(int l=0; l<3; l++) {
	    if(used[arr[i*3+k][j*3+l]] > 1) {
	      output[(i*3+k)][2*(j*3+l)] = '*';
	    }
	  }
	}
	
      }
    }
    
    for(int i=0; i<9; i++) {
      cout << output[i] << endl;
    }
    
  }
  
  return 0;
}

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


int table[9][9];
bool memo[9][9];


void solve(){
	for (int i = 0; i < 9; i++){
		for (int j = 0; j < 8; j++){
			for (int k = j + 1; k < 9; k++){
				if (table[i][j] == table[i][k]) memo[i][j] = memo[i][k] = true;
				if (table[j][i] == table[k][i]) memo[j][i] = memo[k][i] = true;
			}
		}
	}
}


int main(){
	int n;

	cin >> n;

	for (int i = 0; i < n; i++){
		for (int y = 0; y < 9; y++){
			for (int x = 0; x < 9; x++){
				cin >> table[y][x];
			}
		}
		solve();

		for (int y = 0; y < 9; y++){
			for (int x = 0; x < 9; x++){
				if (memo[y][x]) cout << "*";
				else cout << " ";
				cout << table[y][x];
				if (x == 8) cout << endl;
			}
		}
		cout << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,m[9][9],f[9][9];

int main(){
	cin>>n;
	while(n--){
		memset(f,0,sizeof(f));
		rep(i,9)rep(j,9)cin>>m[i][j];
		rep(i,9){
			rep(j,9)rep2(k,j+1,9){
				if(m[i][j]==m[i][k])f[i][j]=f[i][k]=1;
				if(m[j][i]==m[k][i])f[j][i]=f[k][i]=1;
			}
		}
		rep(i,3)rep(j,3){
			rep(ii,3)rep(jj,3)rep(iii,3)rep(jjj,3){
				if((ii!=iii||jj!=jjj)&&m[i*3+ii][j*3+jj]==m[i*3+iii][j*3+jjj]){
					f[i*3+ii][j*3+jj]=f[i*3+iii][j*3+jjj]=1;
				}
			}
		}
		rep(i,9){
			rep(j,9)cout<<(f[i][j]?"*":" ")<<m[i][j];
			cout<<endl;
		}
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main() {
	int N;
	cin >> N;
	REP(n, N) {
		if (n) puts("");
		
		int maps[9][9];
		bool ans[9][9] = {};
		
		REP(i, 9) REP(j, 9) {
			scanf("%d", &maps[i][j]);
			maps[i][j]--;
		}
		
		REP(i, 3) REP(j, 3) {
			int cnt[9] = {};
			REP(k, 3) REP(l, 3) cnt[maps[i * 3 + k][j * 3 + l]]++;
			REP(k, 3) REP(l, 3) if (cnt[maps[i * 3 + k][j * 3 + l]] > 1)
				ans[i * 3 + k][j * 3 + l] = true;
		}
		
		REP(i, 9) {
			int cnt[9] = {};
			REP(j, 9) cnt[maps[i][j]]++;
			REP(j, 9) if (cnt[maps[i][j]] > 1) ans[i][j] = true;
			
			memset(cnt, 0, sizeof(cnt));
			REP(j, 9) cnt[maps[j][i]]++;
			REP(j, 9) if (cnt[maps[j][i]] > 1) ans[j][i] = true;
		}
		
		REP(i, 9) {
			REP(j, 9) printf("%c%d", ans[i][j] ? '*' : ' ', maps[i][j] + 1);
			puts("");
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <utility>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef pair<int,int> p;
int cen[]={1,4,7};
int main()
{
    int n;
	cin>>n;
	while(n--){
		int a[9][9];
		bool cor[9][9];
		
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++){
				cin>>a[i][j];
				cor[i][j]=true;
			}
		for(int i=0;i<9;i++){
			int check[9]={};
			for(int j=0;j<9;j++)check[a[i][j]-1]++;
			for(int j=0;j<9;j++)if(check[a[i][j]-1]!=1)cor[i][j]=false;
		}
		for(int i=0;i<9;i++){
			int check[9]={};
			for(int j=0;j<9;j++)check[a[j][i]-1]++;
			for(int j=0;j<9;j++)if(check[a[j][i]-1]!=1)cor[j][i]=false;
		}
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++){
				int check[9]={};
				for(int kx=-1;kx<=1;kx++)
					for(int ky=-1;ky<=1;ky++){
						int nx=cen[i]+kx,ny=cen[j]+ky;
						check[a[nx][ny]-1]++;
					}
					if(check[a[i][j]-1]!=1)cor[i][j]=false;
			}
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				printf(cor[i][j]?" %d":"*%d",a[i][j]);
			}
			cout<<endl;
		}
	}
    return 0;
}