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

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

int main()
{
	int N;
	cin >> N;
	for (size_t p = 0; p < N; p++)
	{
		int data[9][9];
		bool ans[9][9] = {};
		for (size_t i = 0; i < 9; i++)
		{
			for (size_t j = 0; j < 9; j++)
			{
				cin >> data[i][j];
				data[i][j]--;
			}
		}
		for (size_t i = 0; i < 9; i++)
		{
			int a[9] = {}, b[9] = {};
			for (size_t j = 0; j < 9; j++)
			{
				a[data[i][j]]++;
				b[data[j][i]]++;
			}
			for (size_t j = 0; j < 9; j++)
			{
				if (a[j] != 1)
				{
					for (size_t k = 0; k < 9; k++)
					{
						if (data[i][k] == j)
						{
							ans[i][k] = 1;
						}
					}
				}
				if (b[j] != 1)
				{
					for (size_t k = 0; k < 9; k++)
					{
						if (data[k][i] == j)
						{
							ans[k][i] = 1;
						}
					}
				}
			}
		}
		for (size_t i = 0; i < 3; i++)
		{
			for (size_t j = 0; j < 3; j++)
			{
				int c[9] = {};
				for (size_t k = 0; k < 3; k++)
				{
					for (size_t l = 0; l < 3; l++)
					{
						c[data[i * 3 + k][j * 3 + l]]++;
					}
				}
				for (size_t k = 0; k < 9; k++)
				{
					if (c[k] != 1)
					{
						for (size_t l = 0; l < 3; l++)
						{
							for (size_t m = 0; m < 3; m++)
							{
								if (data[i * 3 + l][j * 3 + m] == k)
								{
									ans[i * 3 + l][j * 3 + m] = 1;
								}
							}
						}
					}
				}
			}
		}
		for (size_t i = 0; i < 9; i++)
		{
			for (size_t j = 0; j < 9; j++)
			{
				cout << (ans[i][j] ? "*" : " ") << data[i][j] + 1;
			}
			cout << endl;
		}
		if (p != N - 1)
		{
			cout << endl;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int p[9][9];

int as(int, int);
int sq(int, int);

int main() {

	int n;

	cin >> n;
	for(int c=0; c<n; c++) {
		if(c) {
			cout << endl;
		}
		for(int i=0; i<9; i++) {
			for(int j=0; j<9; j++) {
				cin >> p[i][j];
			}
		}
							
		for(int i=0; i<9; i++) {
			for(int j=0; j<9; j++) {
				cout << ((as(i, j)||sq(i, j)) ? "*" : " ") << p[i][j];
			}
			cout << endl;
		}
	}

	return 0;

}


int as(int i, int j) {

	int f=0;

	for(int k=0; k<9; k++) {
		if((p[i][j]==p[k][j]||p[i][j]==p[i][k])&&!(i==k||j==k)) {
			f++;
		}
	}
	return (f ? 1 : 0);

}

int sq(int i, int j) {

	int f=0, x=(i/3)*3, y=(j/3)*3;

	for(int k=x; k<x+3; k++) {
		for(int l=y; l<y+3; l++) {
			if(p[i][j]==p[k][l]&&!(i==k&&j==l)) {
				f++;
			}
		}
	}
	if(f) {
		return 1;
	}
	return 0;

}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

void cnc(int q[9], int ct[10]){
	rep(i,10) ct[i] = 0;
	rep(i,9) ct[q[i]]++;
}

int main(void){

  int n;
	int st[9][2] ={{0,0},{0,3},{0,6},{3,0},{3,3},{3,6},{6,0},{6,3},{6,6}};
	while(cin >> n){
		bool kg=false;
		if(cin.eof()) break;
		int w[9][9]={0};
		
		rep(i,n){
			if(kg) cout << endl;
			rep(j,9) rep(k,9) cin >> w[j][k];
			int wk[9]={0}, wt[10]={0};
			bool rr[9][9]={false};
			rep(j,9){
				rep(k,9) wk[k] = w[j][k];
				cnc(wk,wt);
				rep(k,9) if(wt[w[j][k]] > 1) rr[j][k]=true;

				rep(k,9) wk[k] = w[k][j];
				cnc(wk,wt);
				rep(k,9) if(wt[w[k][j]] > 1) rr[k][j]=true;

				rep(k,9) wk[k] = w[st[j][0]+k/3][st[j][1]+k%3];
				cnc(wk,wt);
				rep(k,9) if(wt[w[st[j][0]+k/3][st[j][1]+k%3]] > 1) rr[st[j][0]+k/3][st[j][1]+k%3]=true;
			}
			rep(j,9) rep(k,9){
				cout << (rr[j][k]? "*": " ");
				cout << w[j][k];
				cout << (k>7? "\n": "");
			}
			kg=true;
		}
	}
	return 0;
	
}

C++: #include<stdio.h>
int table[9][9];
bool NG[9][9];
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				scanf("%d",&table[i][j]);
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				NG[i][j]=false;
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				bool ok=true;
				for(int k=0;k<9;k++){
					if(table[i][j]==table[i][k]&&j!=k)ok=false;
				}
				for(int k=0;k<9;k++){
					if(table[i][j]==table[k][j]&&i!=k)ok=false;
				}
				int seci=i/3;
				int secj=j/3;
				for(int k=0;k<3;k++){
					for(int 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)NG[i][j]=true;
			}
		}
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				printf(NG[i][j]?"*":" ");
				printf("%d",table[i][j]);
			}
			printf("\n");
		}
		if(a)printf("\n");
	}
}