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
#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) 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 <cstring>
#define rep(i,n) for(int i = 0 ; i < n ; i++)

using namespace std;

int puzzle[9][9];

void field(int x,int &to,int &from){
  if(0 <= x && x < 3){
    to = 0;
    from = 3;
  }else if(3 <= x && x < 6){
    to = 3;
    from = 6;
  }else{
    to = 6;
    from = 9;
  }
}

bool check1(int x,int y){
  for(int i = x-1 ; i >= 0 ; i--){
    if(puzzle[x][y] == puzzle[i][y]) return false;
  }
  for(int i = x+1 ; i < 9 ; i++){
    if(puzzle[x][y] == puzzle[i][y]) return false;
  }

  return true;
}

bool check2(int x,int y){
  for(int i = y-1 ; i >= 0 ; i--){
    if(puzzle[x][y] == puzzle[x][i]) return false;
  }
  for(int i = y+1 ; i < 9 ; i++){
    if(puzzle[x][y] == puzzle[x][i]) return false;
  }

  return true;
}

bool check3(int x,int y){
  int sx,tx,sy,ty;

  field(x,sx,tx);
  field(y,sy,ty);

  for(int i = sx ; i < tx ; i++){
    for(int j = sy ; j < ty ; j++){
      
      if(x == i && y == j) continue;
      if(puzzle[x][y] == puzzle[i][j]) return false;
    }
  }

  return true;
}

int main(){
  int T;

  cin >> T;
  rep(t,T){
    if(t) cout << endl;

    rep(i,9){
      rep(j,9){
	cin >> puzzle[i][j];
      }
    }

    char ch[9][9];
    rep(i,9){
      rep(j,9){
	ch[i][j] = ' ';
      }
    }

    rep(i,9){
      rep(j,9){
	if(check1(i,j) && check2(i,j) && check3(i,j)) continue;
	ch[i][j] = '*';
      }
    }

    rep(i,9){
      rep(j,9){
	cout << ch[i][j] << puzzle[i][j];
      }
      cout << endl;
    }
  }

  return 0;
}

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

int board[9][9];
bool ok[9][9];

void check() {
    int cnt[10] = {};
    for(int i=0; i<9; ++i) {
        memset(cnt, 0, sizeof(cnt));
        for(int j=0; j<9; ++j) cnt[board[i][j]]++;
        for(int j=0; j<9; ++j)
            if(cnt[board[i][j]] > 1) ok[i][j] = false;

        memset(cnt, 0, sizeof(cnt));
        for(int j=0; j<9; ++j) cnt[board[j][i]]++;
        for(int j=0; j<9; ++j)
            if(cnt[board[j][i]] > 1) ok[j][i] = false;
    }

    for(int i=0; i<3; ++i)
        for(int j=0; j<3; ++j) {
            memset(cnt, 0, sizeof(cnt));
            for(int k=0; k<3; ++k)
                for(int l=0; l<3; ++l)
                    cnt[board[i*3+k][j*3+l]]++;

            for(int k=0; k<3; ++k)
                for(int l=0; l<3; ++l)
                    if(cnt[board[i*3+k][j*3+l]] > 1) ok[i*3+k][j*3+l] = false;
        }
}

int main() {
    int n;
    bool first = true;
    cin>>n;
    while(n--) {
        if(!first) cout<<endl;
        first = false;

        for(int i=0; i<9; ++i)
            for(int j=0; j<9; ++j)
                cin>>board[i][j];
        memset(ok, true, sizeof(ok));
        check();

        for(int i=0; i<9; ++i) {
            for(int j=0; j<9; ++j)
                cout<<((ok[i][j])?" ":"*")<<board[i][j];
            cout<<endl;
        }
    }
}