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++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep) {
        vector<string> v;
        stringstream ss(str);
        string buffer;
        while (getline(ss, buffer, sep)) {
                v.push_back(buffer);
        }
        return v;
}

template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
        return accumulate(begin, end, 0ll);
}

void solve();

signed main() {
        cout << fixed << setprecision(20);
        solve();
        while(true) {
                char s[MAX];
                if (scanf("%s", s) == EOF) break;
                int n = strlen(s);
                for (int i = n - 1; i > -1; i--) {
                        ungetc(s[i], stdin);
                }
                solve();
        }
        return 0;
}

int t;
int a[10][10];
bool wrong[10][10];

void check1() {
        rep(i, 9) {
                map<int, int> map1;
                rep(j, 9) {
                        map1[a[i][j]]++;
                }
                rep(j, 9) {
                        if (map1[a[i][j]] > 1) {
                                wrong[i][j] = true;
                        }
                }
        }
}

void check2() {
        rep(j, 9) {
                map<int, int> map1;
                rep(i, 9) {
                        map1[a[i][j]]++;
                }
                rep(i, 9) {
                        if (map1[a[i][j]] > 1) {
                                wrong[i][j] = true;
                        }
                }
        }
}

void check3() {
        rep(i, 3) rep(j, 3) {
                map<int, int> map1;
                rep(k, 3) rep(l, 3) {
                        map1[a[3*i + k][3*j + l]]++;
                }
                rep(k, 3) rep(l, 3) {
                        if (map1[a[3*i + k][3*j + l]] > 1) {
                                wrong[3*i + k][3*j + l] = true;
                        }
                }
        }
}

void solve() {
        cin >> t;
        rep(loop, t) {
                rep(i, 9) rep(j, 9) wrong[i][j] = false;
                rep(i, 9) rep(j, 9) cin >> a[i][j];
                check1();
                check2();
                check3();
                rep(i, 9) {
                        rep(j, 9) {
                                cout << (wrong[i][j] ? "*" : " ") << a[i][j];
                        }
                        cout << endl;
                }
                if (loop != t-1) {
                        cout << endl;
                 }
        }
}

C++: #include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int f[9][9];

signed main(void){
  int i, j, k;
  int(n);
  for(int testcase = 0;testcase < n;testcase++){
    rep(i, 9)rep(j, 9)scanf("%d", &f[i][j]);
    rep(i, 9){
      rep(j, 9){
        bool is = true;
        rep(k, 9){
          if(i != k)if(f[i][j] == f[k][j])is = false;
          if(j != k)if(f[i][j] == f[i][k])is = false;
        }
        if(is)printf(" %d", f[i][j]);
        else printf("*%d", f[i][j]);
      }
      puts("");
    }


//*/

//*/ break;
  }
  return 0;
}