import sys input = sys.stdin.readline N=int(input()) A=list(map(int,input().split())) B=[list(map(int,input().split())) for i in range(N)] ANS=0 ANSIND=[] for i in range(1<