ls = []
def onoff(n):
    global ls
    if len(n) == 10:
        ls.append(n)
    else:
        onoff(n + '0')
        onoff(n + '1')
onoff('0')
onoff('1')
del ls[0]
n = int(input())
f = [list(map(str,input().split())) for x in range(n)]
p = [list(map(int,input().split())) for x in range(n)]
ans = -99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
for i in range(1024):
    check = 0
    for j in range(n):
        count = 0
        for k in range(10):
            if ls[i][k] == f[j][k] and ls[i][k] == '1':
                count += 1
        check += p[j][count]
    ans = max(ans,check)
print(ans)