class test():
def __init__(self):
self.m=0
self.s=[]
self.err=0
self.t=[0 for i in range(9)]
self.win=0
self.best=0
def read(self):
t=int(input(""))
self.m=t
t=input("")
self.s=t.split()
self.s=[int(i) for i in self.s]
def cal(self):
for i in range(len(self.s)):
if self.t[self.s[i]-1]==0:
if self.m==1:
self.t[self.s[i]-1]=i%2+1
else:
self.t[self.s[i]-1]=2-i%2
else:
self.err=1
break
self.win=self.judge()
flag=0
for i in range(9):
if self.t[i]==0:
flag=1
if flag==1 and self.win==0:
print(1)
self.win=3
for i in range(9):
if self.t[i]==0:
self.t[i]=2
if(self.judge()==2):
self.best=(i+1)
self.t[i]=0
if self.best==0:
self.best=1
def judge(self):
win=0
for i in range(3):
if self.t[i*3]==1 and self.t[i*3+1]==1 and self.t[i*3+2]==1:
win=1
if self.t[i]==1 and self.t[3+i]==1 and self.t[6+i]==1:
win=1
for i in range(3):
if self.t[i*3]==2 and self.t[i*3+1]==2 and self.t[i*3+2]==2:
win=2
if self.t[i]==2 and self.t[3+i]==2 and self.t[6+i]==2:
win=2
if self.t[0]==2 and self.t[4]==2 and self.t[8]==2:
win=2
if self.t[2]==2 and self.t[4]==2 and self.t[6]==2:
win=2
if self.t[0]==1 and self.t[4]==1 and self.t[8]==1:
win=1
if self.t[2]==1 and self.t[4]==1 and self.t[6]==1:
win=1
return win
def draw(self):
if self.err==0:
print('OK')
else:
print('Error')
for i in range(3):
print(self.t[i*3],self.t[i*3+1],self.t[i*3+2])
if self.win==1:
print('Player win')
if self.win==2:
print('Computer win')
if self.win==0:
print('Tie')
if self.win==3:
print('Undecided')
print(self.best)
a=test()
a.read()
a.cal()
a.draw()