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++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  rep(_, n) {
    vvi v(9, vi(9)), c(9, vi(9));
    rep(i, 9) rep(j, 9) cin >> v[i][j];
    rep(i, 9) rep(j, 9) {
      int x  = v[i][j];
      auto f = [&]() {
        int c = 0;
        rep(k, 9) c += v[i][k] == x;
        return c > 1;
      };
      auto g = [&]() {
        int c = 0;
        rep(k, 9) c += v[k][j] == x;
        return c > 1;
      };
      auto h = [&]() {
        int c = 0;
        rep(k, 3) rep(l, 3) c += v[i / 3 * 3 + k][j / 3 * 3 + l] == x;
        return c > 1;
      };
      c[i][j] = f() || g() || h();
    }
    rep(i, 9) {
      rep(j, 9) cout << (c[i][j] ? "*" : " ") << v[i][j];
      cout << endl;
    }
    if (_ != n - 1) cout << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  int T;
  cin >> T;
  for(int t=0; t<T; t++) {
    if(t) cout << endl;
    int a[9][9];
    for(int i=0;i<9;i++)for(int j=0;j<9;j++) cin >> a[i][j];
    bool u[9][9];
    memset(u,false,sizeof(u));
    for(int i=0;i<9;i++) {
      for(int j=0;j<9;j++) {
        for(int k=0;k<9;k++) {
          if(i!=k&&a[i][j]==a[k][j]) u[i][j]=u[k][j]=1;
          if(j!=k&&a[i][j]==a[i][k]) u[i][j]=u[i][k]=1;
        }
        for(int k=0;k<3;k++) {
          for(int l=0;l<3;l++) {
            int x=i/3*3+k,y=j/3*3+l;
            if((i!=x||j!=y)&&a[i][j]==a[x][y]) u[i][j]=u[x][y]=1;
          }
        }
      }
    }
    for(int i=0;i<9;i++) {
      for(int j=0;j<9;j++) {
        if(u[i][j]) cout << '*';
        else cout << ' ';
        cout << a[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n,i,j,k,l,m,a,b;
  int number[10][10];
  bool wrong[10][10];//wrong??????true*
  int check[10]={};
 
  cin>>n;

  rep(i,n){
    if(i)cout<<endl;
    rep(j,9)rep(k,9){
      wrong[j][k]=false;
      scanf("%d",&number[j][k]);
    }

    rep(j,9){//yoko check
      rep(k,10)
	check[k]=0;//0??§?????????
      rep(k,9){
	check[number[j][k]]++;
	if(check[number[j][k]]>1){//2nd
	  rep(l,9)
	    if(number[j][l]==number[j][k])
	      wrong[j][l]=true;
	    
	}
      }//repk
    }//repj
    

    rep(k,9){//tate check
      rep(j,10)
	check[k]=0;//?????????
      rep(j,8){
	for(l=j+1;l<9;l++)
	  if(number[j][k]==number[l][k]){
	    wrong[j][k]=true;
	    wrong[l][k]=true;
	  }
      }//repj
    }//repk
    
    rep(j,3){//block check
      rep(k,3){
	rep(l,10)
	  check[l]=0;//?????????
	rep(l,3)
	  rep(m,3){
	  check[number[3*j+l][3*k+m]]++;
	  if(check[number[3*j+l][3*k+m]]>1){//2nd
	    rep(a,3)
	      rep(b,3)
	      if(number[3*j+a][3*k+b]==number[3*j+l][3*k+m])
		wrong[3*j+a][3*k+b]=true;
	      
	  }
	}
      }//repk
    }//repj

    rep(j,9){
      rep(k,9){
	if(wrong[j][k])
	  cout<<"*";
	else 
	  cout<<" ";
	cout<<number[j][k];
      }
      cout<<endl;
    }


 
  }
}

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;
                        }
                    }
                }
            }
        }
    }
    rep(i,9){
        rep(j,9){
            if(flag[i][j])cout<<" ";
            else cout<<"*";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
};