from __future__ import print_function import fileinput as FI import itertools as IT INP =IT.chain(FI.input(), [""]) while True: line = INP.next() line = line.strip() if not line: break count=int(line) arr=[] linesets=[] columnsets=[] for i in range(count): li = INP.next().strip() arr.append(li) linesets.append(set(li)) flag = True R = 0 while linesets[R] == linesets[R+1]: R+=1 R+=1 # this one is the wrong one! if R == 1: #determine, whether the first is bad or second R = 1 if linesets[0] == linesets[2] else 0 #decide V #print(linesets[(R+1)%count], linesets[R], linesets[(R+1)%count] - linesets[R]) #print(R,count, (R+1)%count) remeaning=linesets[(R+1)%count] - linesets[R] V=list(remeaning)[0] #decide C for i in range(count): columnsets.append(set([li[i] for li in arr])) C=0 while columnsets[C] == columnsets[C+1]: C+=1 C+=1 #this one is the wrong one if C == 1: #determine, whether the first is bad or second C = 1 if columnsets[0] == columnsets[2] else 0 #print + transform from Pythonic indexing to tribune task indexing print("%d %d %s"%(R+1,C+1,V))