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++: #include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<vector<int>> v(9,vector<int>(9,0));
  vector<vector<char>> v2(9,vector<char>(9,' '));
  rep(i,n){
    if( i != 0) cout << endl;
    rep(i,9){
      rep(j,9){
        cin>>v[j][i];
      }
    }
    rep(i,9){
      int num[10] = {};
      rep(j,9){
        num[v[j][i]]++;
      }
      rep(j,9){
        if(num[v[j][i]] > 1){
          v2[j][i] = '*';
        }
      }
    }
    rep(j,9){
      int num[10] = {};
      rep(i,9){
        num[v[j][i]]++;
      }
      rep(i,9){
        if(num[v[j][i]] > 1){
          v2[j][i] = '*';
        }
      }
    }
    for(int i = 0; i < 9 ; i+= 3){
      for(int j = 0; j < 9; j += 3){
        int num[10]={};
        rep(k,3){
          rep(l,3){
            num[v[j+l][i+k]]++;
          }
        }
        rep(k,3){
          rep(l,3){
            if(num[v[j+l][i+k]] > 1){
              v2[j+l][i+k] = '*';
            }
          }
        }
      }
    }
    rep(i,9){
      rep(j,9){
        cout << v2[j][i]<<v[j][i];
      }
      cout << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
const int N = 9;

vector <string> disp_res (vector <vector <int> > t, vector <vector<bool> > c )
{
	int size = t.size();
	int len  = t[0].size();
	int i,j;
	vector <string> res (size);

	for (i = 0; i < size; ++i ){
		for (j = 0; j < len; ++j ){
			if (c[i][j]){
//				cout << ' ' << t[i][j];
				res[i] += ' ';
			}else{
				res[i] += '*';
//				cout << '*' << t[i][j];
			} // end if
			res[i] += (t[i][j] + '0');
		} // end for
//		cout << endl;
	} // end for

	return res;
}

void iscorrect (vector <vector <int> > b, vector <vector <bool> >& c )
{
	int i,j,k,m;

	// search hight
	for (j = 0; j < N; ++j){
		vector <vector <int> > used(N + 1);
		for (i = 0; i < N; ++i){
//			cout << b[i][j] << ' ';
			used[b[i][j]].push_back(i);
		} // end for
//		cout << endl;
		for (m = 1; m <= N; ++m){
			if (!used[m].empty() && used[m].size() == 1){
				continue;
			} // end if
			if (!used[m].empty() && used[m].size() > 1){
				for (k = 0; k < used[m].size(); ++k){
					c[used[m][k]][j] = false;
				} // end if
			} // end if
		} // end for
		used.clear();	
	} // end for

	// search width
	for (i = 0; i < N; ++i){
		vector <vector <int> > used(N + 1);
		for (j = 0; j < N; ++j){
//			cout << b[i][j] << ' ';
			used[b[i][j]].push_back(j);
		} // end for
//		cout << endl;
		for (m = 1; m <= N; ++m){
			if (!used[m].empty() && used[m].size() == 1){
				continue;
			} // end if
			if (!used[m].empty() && used[m].size() > 1){
				for (k = 0; k < used[m].size(); ++k){
					c[i][used[m][k]] = false;
				} // end if
			} // end if
		} // end for
		used.clear();	
	} // end for

	// search block
	for (i = 0; i < N; i += 3){
		for (j = 0; j < N; j += 3){
			vector <vector <int> > used (N + 1);
			for (k = 0; k < N; ++ k){
				int row = i + k / 3;
				int col = j + (k % 3);
//				cout << b[row][col] << ' ';
				used[b[row][col]].push_back(k);
			} // end for
//			cout << endl;
			for (m = 1; m <= N; ++m){
				if (!used[m].empty() && used[m].size() == 1){
					continue;
				} // end if
				if (!used[m].empty() && used[m].size() > 1){
					for (k = 0; k < used[m].size(); ++k){
						c[ i + used[m][k]/3 ][ j + (used[m][k] % 3) ] = false;
					} // end if
				} // end if
			} // end for
			used.clear();	
		} // end for
	} // end for


}
template<class T> void setup (vector <vector<T> > &c, T n )
{
	int size = c.size();
	int len  = c[0].size();
	int i,j;

	for (i = 0; i < size; ++i){
		for (j = 0; j < len; ++j){
			c[i][j] = n;
		} // end for
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.suudoku", "r", stdin );
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;
	int i,j;

	vector <vector <int> >  b(N, vector <int>(N, 0 ) );
	vector <vector <bool> > c(N, vector <bool>(N, true ) );
	vector <vector <string> > res;

	for (i = 0; i < N*n; ++i){

		getline (cin, str );
		stringstream ss(str );

		for (j = 0; j < N; ++j){
			int num;
			ss >> num;
			b[i % N][j] = num;
		} // end for
	
		if (i % N == N - 1 ){
			iscorrect (b, c );
			vector <string> r;
			r = disp_res (b, c );
			res.push_back (r );
			setup (b, 0 );
			setup (c, true );
		} // end if
	} // end for

	int size = res.size();

	for (i = 0; i < size; ++i){
		vector<string>::iterator it = res[i].begin();
		for (; it != res[i].end(); ++it ){
			string str = (*it);
			int len = str.size();

			for (j = 0; j < len; ++j){
				cout << str[j];
			} // end for
			cout << endl;
		} // end for

		if (i != size - 1){
			cout << endl;
		} // end if

	} // end for
		
	return 0;
}