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++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl;
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	int n; cin >> n;
	rep(i, n) {
		vector<vector<pair<int, bool>>> a(9, vector<pair<int, bool>>(9));
		rep(i, 9)rep(j, 9)cin >> a[i][j].first;

		//yoko
		rep(i, 9) {
			rep(j, 8)FOR(k, j + 1, 9) {
				if (a[i][j].first == a[i][k].first) {
					a[i][j].second = true; a[i][k].second = true;
				}
			}
		}

		//tate
		rep(i, 9) {
			rep(j, 8)FOR(k, j + 1, 9) {
				if (a[j][i].first == a[k][i].first) {
					a[j][i].second = true; a[k][i].second = true;
				}
			}
		}

		//3x3
		for (int i = 0; i < 9; i += 3)for (int i2 = 0; i2 < 9; i2 += 3) {
			FOR(j, i, i + 3)FOR(j2, i2, i2 + 3) {
				FOR(k, i, i + 3)FOR(k2, i2, i2 + 3) {
					if ((j != k || j2 != k2) && a[j][j2].first == a[k][k2].first) {
						a[j][j2].second = true; a[k][k2].second = true;
					}
				}
			}
		}

		rep(i, 9) {
			rep(j, 9) {
				printf(a[i][j].second ? "*" : " ");
				cout << a[i][j].first;
			}
			puts("");
		}
		if (i != n - 1)puts("");
	}
}

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

int main(){
	int n;
	cin >> n;
	// input
	for( int t = 0; t < n; t++ ){
		int puzzle[9][9];
		int row[9][9] = {{0}}, col[9][9] = {{0}}, rect[9][9] = {{0}};
		for( int i = 0; i < 9; i++ ){
			for( int j = 0; j < 9; j++ ){
				cin >> puzzle[i][j];
				/*if( row[i][puzzle[i][j]-1] == 1 ) row[i][puzzle[i][j]-1] = -1;
				else row[i][puzzle[i][j]-1] = 1;
				if( col[j][puzzle[i][j]-1] == 1 ) col[j][puzzle[i][j]-1] = -1;
				else col[j][puzzle[i][j]-1] = 1;
				*/
				if( rect[i/3*3+j/3][puzzle[i][j]-1] == 1 ) rect[i/3*3+j/3][puzzle[i][j]-1] = -1;
				else rect[i/3*3+j/3][puzzle[i][j]-1] = 1;
			}
		}

		// output
		if( t != 0 ) cout << endl;
		for( int i = 0; i < 9; i++ ){
			for( int j = 0; j < 9; j++ ){
				if( row[i][puzzle[i][j]-1] == -1 || col[j][puzzle[i][j]-1] == -1 || rect[i/3*3+j/3][puzzle[i][j]-1] == -1 ) cout << "*";
				else cout << " ";
				cout << puzzle[i][j];
			}
			cout << endl;
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  cin >> n;
  REP(datan,n) {
    if (datan) cout << endl;
    int ba[9][9];
    REP(y,9)
      REP(x,9)
      cin >> ba[x][y];
    multiset<int> block[3][3];
    multiset<int> yoko[9];
    multiset<int> tate[9];
    REP(i,3)
      REP(j,3)
        for (int x = i*3; x<(i+1)*3; x++)
          for (int y = j*3; y<(j+1)*3; y++)
            block[i][j].insert(ba[x][y]);
    REP(i,9) {
      REP(x,9)
        yoko[i].insert(ba[x][i]);
      REP(y,9)
        tate[i].insert(ba[i][y]);
    }
    REP(y,9) {
      REP(x,9) {
        int a = ba[x][y];
        if (block[x/3][y/3].count(a) == 2 || yoko[y].count(a) == 2 || tate[x].count(a) == 2)
          cout << "*";
        else
          cout << " ";
        cout << a;
      }
      cout << endl;
    }
  }
}

C++: /*****include*****/
#include <iostream>
#include <set>
/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
/*****変数置き場*****/
	int n;
	int field[11][11];
	bool wrong[10];
	bool fail[11][11];
	int table_x[] = {0,1,2,0,1,2,0,1,2};
	int table_y[] = {0,0,0,1,1,1,2,2,2};
	set <int>appear;
	/*****処理部*****/
	cin >> n;
	while(n>0){
		n--;
		for(int i=0;i<11;i++)
			for(int j=0;j<11;j++){
				field[i][j] = 0;
				fail[i][j] = 0;
			}
		for(int i=0;i<10;i++)
			wrong[i] = false;
		for(int i=1;i<=9;i++)
			for(int j=1;j<=9;j++)
				cin >> field[i][j];
		appear.clear();
		
		for(int i=1;i<=9;i++){
			for(int j=1;j<=9;j++){
				if(appear.find(field[i][j]) != appear.end()){
					wrong[field[i][j]] = true;
				}else
					appear.insert(field[i][j]);
			}
			appear.clear();
			for(int k=1;k<=9;k++)
				if(wrong[field[i][k]])
					fail[i][k] = true;
			for(int k=0;k<10;k++){
				wrong[k] = false;
			}
		}
		for(int j=1;j<=9;j++){
			for(int i=1;i<=9;i++){
				if(appear.find(field[i][j]) != appear.end()){
					wrong[field[i][j]] = true;
				}else
					appear.insert(field[i][j]);
			}
			appear.clear();
			for(int k=1;k<=9;k++)
				if(wrong[field[k][j]])
					fail[k][j] = true;
			for(int k=0;k<10;k++){
				wrong[k] = false;
			}
		}

		for(int i=1;i<=9;i+=3)
			for(int j=1;j<=9;j+=3){
				for(int k=0;k<9;k++)
					if(appear.find(field[i+table_y[k]][j+table_x[k]]) != appear.end())
						wrong[field[i+table_y[k]][j+table_x[k]]] = true;
					else
						appear.insert(field[i+table_y[k]][j+table_x[k]]);
				appear.clear();
				for(int k=0;k<9;k++)
					if(wrong[field[i+table_y[k]][j+table_x[k]]])
						fail[i+table_y[k]][j+table_x[k]] = true;
				for(int k=0;k<10;k++){
					wrong[k] = false;
				}
			}
		
		for(int i=1;i<=9;i++){
			for(int j=1;j<=9;j++){
				if(fail[i][j])
					cout << "*";
				else
					cout << " ";
				cout << field[i][j];
			}
			cout << endl;
		}
		if(n!=0)	cout << endl;
	}
	/*****処理終了後*****/
	return 0;
}