#!/usr/bin/env python3

from itertools import product

def main():
    n = int(input())
    f = []
    p = []
    for ob in (f, p):
        for i in range(n):
            ro = list(map(int, input().split()))
            ob.append(ro)
    res = -999999999
    for open_at in product((0, 1), repeat=10):
        if 1 not in open_at:
            continue
        res = max(res, get_rieki(f, p, open_at, n))
    print(res)

def get_rieki(f, p, open_at, n):
    res = 0
    for i in range(n):
        cnt = 0
        for t in range(10):
            if f[i][t] == 1 and open_at[t] == 1:
                cnt += 1
        res += p[i][cnt]
    return res

main()
