import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    F = [[0] * 10 for _ in range(N)]
    for i in range(N):
        s = input().split()
        for j in range(10):
            F[i][j] = int(s[j])
    P = [[0] * 10 for _ in range(N)]
    for i in range(N):
        s = input().split()
        for j in range(10):
            P[i][j] = int(s[j])

    ans = -INF
    # 2 ^ nの組み合わせの全列挙
    for b in range(1, 2 ** 10):
        o = [0] * 10
        for i in range(10):
            if b & 1 << i:
                o[i] = 1

        total = 0
        for i in range(N):
            c = 0
            for j in range(10):
                if o[j] == 1 and F[i][j] == 1:
                    c += 1
            total += P[i][c]
        ans = max(ans, total)
    print(ans)


if __name__ == '__main__':
    main()
