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++: #include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    for (int t = 0; t < n; t++) {
        int a[9][9];
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                cin >> a[i][j];
            }
        }
        bool flag[9][9];
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                flag[i][j] = false;
            }
        }
        for (int i = 1; i < 10; i++) {
            for (int j = 0; j < 9; j++) {
                int count = 0;
                for (int k = 0; k < 9; k++) {
                    if (a[j][k] == i) count++;
                }
                if (count <= 1) continue;
                for (int k = 0; k < 9; k++) {
                    if (a[j][k] == i) flag[j][k] = true;
                }
            }


            for (int j = 0; j < 9; j++) {
                int count = 0;
                for (int k = 0; k < 9; k++) {
                    if (a[k][j] == i) count++;
                }
                if (count <= 1) continue;
                for (int k = 0; k < 9; k++) {
                    if (a[k][j] == i) flag[k][j] = true;
                }
            }

            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    int count = 0;
                    for (int l = 0; l < 3; l++) {
                        for (int o = 0; o < 3; o++) {
                            if (a[j * 3 + l][k * 3 + o] == i) count++;
                        }
                    }
                    if (count <= 1) continue;
                    for (int l = 0; l < 3; l++) {
                        for (int o = 0; o < 3; o++) {
                            if (a[j * 3 + l][k * 3 + o] == i) {
                                flag[j * 3 + l][k * 3 + o] = true;
                            }
                        }
                    }
                }
            }
        }

        if (t) cout << endl;
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                if (flag[i][j]) cout << "*";
                else cout << " ";
                cout << a[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

C++: #include <cstdio>
#include <utility>
#include <cctype>
#include <array>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

template<typename T>
using A = array<T, 9>;

int main() {
	for (int n: range((int) in)) {
		if (n)
			outl();
		A<A<bool>> b {};
		A<A<int>>  p;
		range r9(9), r3(0, 9, 3);
		for (auto &i: p)
			for (auto &j: i)
				j = (int) in - 1;
		for (int i: r9) {
			A<int> t {}, s {};
			for (int j: r9) {
				t[p[i][j]]++;
				s[p[j][i]]++;
			}
			for (int j: r9) {
				b[i][j] |= t[p[i][j]] != 1;
				b[j][i] |= s[p[j][i]] != 1;
			}
		}
		for (int i: r3)
			for (int j: r3) {
				A<int> t {};
				for (int k: r9)
					t[p[i + k / 3][j + k % 3]]++;
				for (int k: r9)
					b[i + k / 3][j + k % 3] |= t[p[i + k / 3][j + k % 3]] != 1;
			}
		for (int i: r9) {
			for (int j: r9)
				out(b[i][j] ? '*' : ' ', p[i][j] + 1);
			outl();
		}
	}
}