import sys readline=sys.stdin.readline write=sys.stdout.write N=int(readline()) A=list(map(int,readline().split())) B=[list(map(int,readline().split())) for i in range(N)] inf=1<<60 ans=-inf ans_bit=0 for bit in range(1<