#ABC080C
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for j in range(N)]
ans =0
for i in range(N):
    profits = 0
    for j in range(10):
        profits += P[i][j] 
    ans = max(ans, profits)
print(ans)