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++: #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("");
        }
    }
}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                             it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n;
    cin >> n;
    rep(nind,n){
        vector<vector<int> > V(9,vector<int>(9));
        //if no -> true;
        vector<vector<bool> > flag(9,vector<bool>(9));

        rep(i,9) rep(j,9){
            cin >> V[i][j];
        }
        rep(i,9){
            vector<int> cnt(10);
            vector<int> cnt2(10);
            rep(j,9){
                cnt[V[i][j]]++;
                cnt2[V[j][i]]++;
            }
            rep(j,9){
                if(cnt[V[i][j]] >= 2)
                    flag[i][j] = true;
                if(cnt2[V[j][i]] >= 2)
                    flag[j][i] = true;
            }
        }
        rep(i,3){
            rep(j,3){
                //i,j is right up.
                vector<int> cnt(10);
                rep(k,3) rep(l,3){
                    cnt[V[3*i+k][3*j+l]]++;
                }

                rep(k,3) rep(l,3){
                    if(cnt[V[3*i+k][3*j+l]] >= 2){
                        flag[3*i+k][3*j+l] = true;
                    }
                }
            }
        }
        rep(i,9){
            rep(j,9){
                cout << (flag[i][j] ? "*" : " ") << V[i][j];
            }
            cout << endl;
        }
        if(nind != n-1) cout << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

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

int main(void){
  int grid[9][9];
  int n;
  cin>>n;
  bool fst = false;
  while(n--){
    if(fst){
      cout<<endl;
    }else{
      fst = true;
    }
    REP(y,9)REP(x,9)cin>>grid[y][x];
    REP(y,9){
      REP(x,9){
        bool f=false;
        int bx = x-x%3;
        int by = y-y%3;
        REP(sx,9){
          if(x==sx) continue;
          if(grid[y][x]==grid[y][sx]) f = true;
        }
        REP(sy,9){
          if(y==sy) continue;
          if(grid[y][x]==grid[sy][x]) f = true;
        }
        REP(dy,3)REP(dx,3){
          if(by+dy==y&&bx+dx==x) continue;
          if(grid[y][x]==grid[by+dy][bx+dx]) f=true;
        }
        if(f) cout<<"*";
        else cout<<" ";
        cout<<grid[y][x];
      }
      cout<<endl;
    }
  }
  return 0;
}