//AMANDA
BOCKOFF
//TOMBALL
HS
//30330
QUINN RD
//TOMBALL,
TX 77375
//DIVISION
INT-3
import
java.io.*;
import
java.util.StringTokenizer;
import
java.util.ArrayList;
public
class ABockoffSudoku
{
public static void main(String[]
args)throws IOException
{
BufferedReader
input=new BufferedReader(new FileReader("ACSLintSpaces.dat"));
int[][]
grid=new int[9][9];
for(int
row=0;row<9;row++)
{
String s1=input.readLine();
StringTokenizer tok1=new
StringTokenizer(s1);
for(int col=0;col<9;col++)
{
grid[row][col]=Integer.parseInt(tok1.nextToken());
}
}
for(int
run=0;run<5;run++)
{
ArrayList list=new ArrayList();
for(int add=1;add<=9;add++)
list.add(new
Integer(add));
String s2=input.readLine();
StringTokenizer tok2=new
StringTokenizer(s2);
int
r=Integer.parseInt(tok2.nextToken())-1;
int
c=Integer.parseInt(tok2.nextToken())-1;
//test row
for(int k=0;k<9;k++)
{
int
num=grid[r][k];
if(list.contains(new
Integer(num)))
{
list.remove(list.indexOf(new
Integer(num)));
}
}
//test column
for(int k=0;k<9;k++)
{
int
num=grid[k][c];
if(list.contains(new
Integer(num)))
{
list.remove(list.indexOf(new
Integer(num)));
}
}
//test minigrid
for(int
k=3*(r/3);k<3*(r/3)+3;k++)
{
for(int
j=3*(c/3);j<3*(c/3)+3;j++)
{
int num=grid[k][j];
if(list.contains(new
Integer(num)))
{
list.remove(list.indexOf(new
Integer(num)));
}
}
}
Integer
woot=(Integer)list.get(0);
grid[r][c]=woot.intValue();
System.out.println(woot);
}
}
}