N=int(input()) A=list(map(int,input().split())) B=[[0]*N for _ in range(N)] for i in range(N): B[i]=list(map(int,input().split())) inf=float("inf") DP=[-inf]*(1<>=1 for i in range(N): C=0 if i not in M: for j in M: C+=B[i][j] DP[x|(1<Max: Max=DP[x] Arg=x print(Max) print(*[i+1 for i in range(N) if Arg&(1<