#!/usr/bin/env python3

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    n = int(input())
    F = []
    for i in range(n):
        F.append(list(map(int, input().split())))
    P = []
    for i in range(n):
        P.append(list(map(int, input().split())))
    mx = -1e9
    for i in range(1, 1 << 10):
        benefit = 0
        for j in range(n):
            f = F[j]
            counter = 0
            for k in range(10):
                if (i >> k & f[k]) == 1:
                    counter += 1
            benefit += P[j][counter]
        mx = max(mx, benefit)
    print(mx)

if __name__ == '__main__':
    main()
