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++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<regex>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int n; cin >> n;
	int m[9][9];
	bool first = true;
	rep(h, 0, n) {
		bool b[9][9] = {};
		if (!first)cout << endl;
		first = false;
		rep(i, 0, 9)rep(j, 0, 9)cin >> m[i][j];

		rep(i, 0, 9) {
			int cnt[10] = {};
			rep(j, 0, 9)cnt[m[i][j]]++;
			rep(j, 0, 9) {
				if (cnt[m[i][j]] >= 2)b[i][j] = true;
			}
		}
		rep(j, 0, 9) {
			int cnt[10] = {};
			rep(i, 0, 9)cnt[m[i][j]]++;
			rep(i, 0, 9) {
				if (cnt[m[i][j]] >= 2)b[i][j] = true;
			}
		}
		for (int i = 0; i < 9; i += 3) {
			for (int j = 0; j < 9; j += 3) {
				int cnt[10] = {};
				rep(I, i, i + 3)rep(J, j, j + 3) {
					cnt[m[I][J]]++;
				}
				rep(I, i, i + 3)rep(J, j, j + 3) {
					if (cnt[m[I][J]] >= 2)b[I][J] = true;
				}
			}
		}
		rep(i, 0, 9) {
			rep(j, 0, 9) {
				if (b[i][j])cout << "*";
				else cout << " ";
				cout << m[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
bool maze[9][9];
void tate(vector<string> s){
  /*
  cout<<"tate"<<endl;
  rep(i,9){
    rep(j,9)
      cout<<s[j][i]<<" ";
    cout<<endl;
  }
  //*/
  rep(i,9){
    //cout<<i<<endl;
    int used[9] = {0};
    rep(j,9){
      used[s[j][i]-'1']++;
    }
    rep(j,9){
      if(used[j] > 1){
	rep(k,9){
	  if(s[k][i] == j + '1')maze[k][i] = false;
	}
      }
    }
  }  
}

void yoko(vector<string> s){
  rep(i,9){
    int used[9] = {0};
    rep(j,9){
      used[s[i][j]-'1']++;
    }
    rep(j,9){
      if(used[j] > 1){
	rep(k,9){
	  if(s[i][k] == j + '1')maze[i][k] = false;
	}
      }
    }
  }    
}

void masu(vector<string> s){
  rep(i,3){
    rep(j,3){
      int used[9] = {0};
      rep(k,3){
	rep(l,3){
	  int x = i * 3 + k, y =  j * 3 + l;
	  //cout<<x<<" "<<y<<" ";
	  used[s[x][y] - '1'] ++;
	}
	//cout<<endl;
      }
      //cout<<endl<<endl;;
      
      //rep(k,9)cout<<used[k]<<" ";cout<<endl;
      rep(k,3){
	rep(l,3){
	  
	  int x = i * 3 + k, y =  j * 3 + l;
	  //cout<<s[x][y]<<" "<<used[s[x][y]-'1']<< " ";
	  if(used[s[x][y] -'1'] >1)
	    maze[x][y] = false;
	    //if(s[x][y] ==  + '1')maze[x][y] = false;
	}
	//	cout<<endl;
      }
      //    cout<<endl;
      
    }
  }
}

int main(void){
  int n;
  cin>>n;
  rep(z,n){
    vector<string> s;
    rep(i,9){
      string str;
      rep(j,9){
	maze[i][j] = true;
	string ss;
	cin>>ss;
	str += ss;
      }
      s.push_back(str);
    }
    if(z)cout<<endl;
    
    tate(s);
    yoko(s);
    masu(s);
    rep(i,9){
      rep(j,9){
	if(maze[i][j])cout<<" ";
	else cout<<"*";
	cout<<s[i][j];
      }
      cout<<endl;
    }
  }
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int x[9][9], n, s[9], cnt[9], p[9][9]; bool a[9][9];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		memset(x, 0, sizeof(x));
		memset(p, 0, sizeof(p));
		memset(a, false, sizeof(a));
		memset(cnt, 0, sizeof(cnt));
		if (n) { cout << endl; }
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				cin >> x[9][9];
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[j][k]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[j][k]] >= 2) {
					a[j][k] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[k][j]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[k][j]] >= 2) {
					a[k][j] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				p[(j / 3) * 3 + (k / 3)][cnt[(j / 3) * 3 + (k / 3)]] = x[j][k];
				cnt[(j / 3) * 3 + (k / 3)]++;
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[j][k]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[j][k]] >= 2) {
					a[j][k] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				if (a[j][k] == true) {
					cout << '*';
				}
				else {
					cout << ' ';
				}
				cout << x[j][k];
			}
			cout << endl;
		}
	}
}

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

int main(){
  int i,j,k,l,n,a[9][9],ans[9][9],c=0;
  while(cin >> n){
    for(i=0;i<n;i++){

      if(c) cout << endl;
      c = 1;

      for(j=0;j<9;j++){
	for(k=0;k<9;k++){
	  cin >> a[j][k];
	  ans[j][k] = 0;
	}
      }

      for(j=0;j<9;j++){
	for(k=0;k<9;k++){
	  for(l=k+1;l<9;l++){
	    if(a[j][k] == a[j][l]) ans[j][k] = ans[j][l] = 1;
	    if(a[k][j] == a[l][j]) ans[k][j] = ans[l][j] = 1;
	  }
	}
      }

      for(j=0;j<=6;j+=3){
	for(int m=0;m<=6;m+=3){
	  for(k=0;k<9;k++){
	    for(l=k+1;l<9;l++){
	      if(a[k/3+j][k%3+m] == a[l/3+j][l%3+m]) ans[k/3+j][k%3+m] = ans[l/3+j][l%3+m] = 1;
	    }
	  }
	}
      }

      for(j=0;j<9;j++){
	for(k=0;k<9;k++){
	  if(ans[j][k]) cout << "*" << a[j][k];
	  else cout << " " << a[j][k];
	}
	cout << endl;
      }

    }
  }
  return 0;
}