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

int main(){
  bool error[10][10];
  int puzzle[10][10];
  
  int T;
  cin >> T;
  while(T--){
    for(int i = 0 ; i < 9 ; i++){
      for(int j = 0 ; j < 9 ; j++){
	cin >> puzzle[i][j];
      }
    }
    
    memset(error, 0, sizeof(error));
    int check1[10];
    int check2[10];
    
    for(int i = 0 ; i < 9 ; i++){
      memset(check1, 0, sizeof(check1));
      memset(check2, 0, sizeof(check2));
      for(int j = 0 ; j < 9 ; j++){
	check1[puzzle[i][j]]++;
	check2[puzzle[j][i]]++;
	
	if(check1[puzzle[i][j]] >= 2){
	  for(int k = 0 ; k < 9 ; k++){
	    if(puzzle[i][k] == puzzle[i][j]) error[i][k] = true;
	  }
	}
	
	if(check2[puzzle[j][i]] >= 2){
	  for(int k = 0 ; k < 9 ; k++){
	    if(puzzle[k][i] == puzzle[j][i]) error[k][i] = true;
	  }
	}
	
      }
    }

    for(int k = 0 ; k < 9 ; k+=3){
      for(int l = 0 ; l < 9 ; l+=3){
	memset(check1, 0, sizeof(check1));
	memset(check2, 0, sizeof(check2));
	for(int i = k ; i < k+3 ; i++){
	  for(int j = l ; j < l+3 ; j++){
	    check1[puzzle[i][j]]++;
	    if(check1[puzzle[i][j]] >= 2){
	      for(int _i = k ; _i < k+3 ; _i++){
		for(int _j = 0 ; _j < 3 ; _j++){
		  if(puzzle[i][j] == puzzle[_i][_j]) error[_i][_j] = true;
		}
	      }
	    }
	  }
	}
      }
    }
    
    for(int i = 0 ; i < 9 ; i++){
      for(int j = 0 ; j < 9 ; j++){
	cout << ((error[i][j]) ? '*' : ' ') << puzzle[i][j];
      }
      cout << endl;
    }
    if(T)cout << endl;
  }
  return 0;
}

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

int main(){
	int q;
	cin >> q;
	for(int Q=0; Q < q; Q++){
		if(Q != 0) cout << endl;
		int field[9][9];
		for(int i=0; i < 9; i++)for(int j=0; j< 9; j++) cin >> field[i][j];
		bool p[9][9];
		for(int i=0; i < 9; i++)for(int j=0; j< 9; j++) p[i][j] = true;
		for(int i=0; i < 9; i++){
			bool n[10] = {false};
			vector<int> v;
			for(int j=0; j < 9; j++) if(!n[field[i][j]]) n[field[i][j]] = true; else v.push_back(field[i][j]);
			for(int j=0; j< v.size(); j++) for(int k=0; k < 9; k++) if(field[i][k] == v[j]) p[i][k] = false;
		}
		for(int i=0; i < 9; i++){
			bool n[10] = {false};
			vector<int> v;
			for(int j=0; j < 9; j++) if(!n[field[j][i]]) n[field[j][i]] = true; else v.push_back(field[j][i]);
			for(int j=0; j< v.size(); j++) for(int k=0; k < 9; k++) if(field[k][i] == v[j]) p[k][i] = false;
		}
		for(int i=0; i< 3; i++){
			for(int j=0; j< 3; j++){
				bool n[10] = {false};
				vector<int> v;
				for(int k=0; k< 9; k++){
					int x = 3*i+k/3, y = 3*j+k%3;
					if(!n[field[x][y]]) n[field[x][y]] = true; else v.push_back(field[x][y]);
				}
				for(int k=0; k < v.size(); k++){
					for(int l=0; l < 9; l++){
						int x = 3*i+l/3, y = 3*j+l%3;
						if(field[x][y] == v[k]) p[x][y] = false;
					}
				}
			}
		}
		for(int i=0; i< 9; i++){
			for(int j=0; j< 9; j++) cout << (p[i][j] ? " " : "*") << field[i][j];
			cout << endl;
		}
	}
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<cstdio>
#include<cmath>
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
	int n;
	cin>>n;
	bool h=false;
	rep(w,n){
	if(h)cout<<endl;
		int in[9][9]={0};
		rep(j,9)rep(k,9)cin>>in[j][k];
		int out[9][9]={0};
		rep(i,9){
			rep(j,9){
				int co=0;
				rep(k,9)if(in[i][k]==j+1)co++;
				if(co>1)rep(k,9)if(in[i][k]==j+1)out[i][k]=1;
			}
		}
		rep(i,9){
			rep(j,9){
				int co=0;
				rep(k,9)if(in[k][i]==j+1)co++;
				if(co>1)rep(k,9)if(in[k][i]==j+1)out[k][i]=1;
			}
		}
		rep(i,3)rep(j,3){
			map<int,int>m;
			rep(a,3)rep(b,3)m[in[3*i+a][3*j+b]]++;
			rep(k,9)if(m[k]>2)rep(a,3)rep(b,3)if(in[3*i+a][3*j+b]==k)out[3*i+a][3*j+b]=1;
		}
		rep(i,9){
			rep(j,9)
				if(out[i][j]==0)cout<<" "<<in[i][j];
				else cout<<"*"<<in[i][j];
			cout<<endl;
		}
		h=true;
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
#include <map>
#include <algorithm>
#include <bitset>
#include <set>
#include <functional>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;
typedef long long int lint;

void init(int* c) {
	REP(i, 10) {
		c[i] = 0;
	}
}

int cy[9] = { 1, 1, 1, 4, 4, 4, 7, 7, 7 };
int cx[9] = { 1, 4, 7, 1, 4, 7, 1, 4, 7 };
int dy[9] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };
int dx[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };

void check(int n) {

	int puz[9][9] = { 0 };
	bool err[9][9] = { 0 };

	REP(i, 9) {
		REP(j, 9) {
			cin >> puz[i][j];
		}
	}

	int* count = new int[10];
	//???????????£???
	REP(i, 9) {
		init(count);
		REP(j, 9) {
			count[puz[i][j]]++;
		}
		FOR(num, 1, 10) {
			if (count[num] > 1) {
				REP(j, 9) {
					if (puz[i][j] == num) err[i][j] = true;
				}
			}
		}
	}
	//???????????£???
	REP(j, 9) {
		init(count);
		REP(i, 9) {
			count[puz[i][j]]++;
		}
		FOR(num, 1, 10) {
			if (count[num] > 1) {
				REP(i, 9) {
					if (puz[i][j] == num) err[i][j] = true;
				}
			}
		}
	}
	//????????????????????£???
	REP(i, 9) {
		init(count);
		REP(j, 9) {
			count[puz[cy[i] + dy[j]][cx[i] + dx[j]]]++;
		}
		FOR(num, 1, 10) {
			if (count[num] > 1) {
				REP(j, 9) {
					if (puz[cy[i] + dy[j]][cx[i] + dx[j]] == num) err[cy[i] + dy[j]][cx[i] + dx[j]] = true;
				}
			}
		}
	}

	if (n != 0) cout << endl;
	REP(i, 9) {
		REP(j, 9) {
			cout << (err[i][j] ? '*' : ' ') << puz[i][j];
		}
		cout << endl;
	}
	
	delete[] count;
}

bool AOJ0124()
{
	int n;
	cin >> n;

	REP(i, n) {
		check(i);
	}

	return true;
}

int main()
{
	AOJ0124();

	return 0;
}