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 <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;
        }
        cout << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n; cin>>n;
    rep(p,n){
    vector<vector<bool> >flag(10,vb(10,true));
    vvi v(10,vi(10,0));
    rep(i,9)rep(j,9)cin>>v[i][j];
    for(int i=0;i<9;i++){
        vb used(10,false);
        for(int j=0; j<9;j++){
            if(!used[v[i][j]]){used[v[i][j]]=true;}
            else {
                flag[i][j]=false;
                rep(k,9)if(v[i][k]==v[i][j])flag[i][k]=false;
            }
        }
    }
    for(int j=0;j<9;j++){
        vb used(10,false);
        for(int i=0; i<9;i++){
            if(!used[v[i][j]]){used[v[i][j]]=true;}
            else {
                flag[i][j]=false;
                rep(k,9)if(v[k][j]==v[i][j])flag[k][j]=false;
            }
        }
    }
   
    for(int h=0; h<=8;h+=3){
        for(int w=0; w<=8;w+=3){
            vb used(10,false);
            for(int i=h; i<h+3;i++){
                for(int j=w; j<w+3;j++){
                    if(!used[v[i][j]])used[v[i][j]]=true;
                    else for(int k=h; k<h+3;k++){
                            for(int m=w; m<w+3;m++){
                                if(v[k][m]==v[i][j])flag[k][m]=false;
                        }
                    }
                }
            }
        }
    }
        cout<<endl;
    rep(i,9){
        rep(j,9){
            if(flag[i][j])cout<<" ";
            else cout<<"*";
            cout<<v[i][j];
        }
        if(p!=n-1||i!=8)cout<<endl;
    }
}
};