#!/usr/bin/env python3
import itertools

def main():
    N = int(input())
    F = [list(map(int,input().split())) for _ in range(N)]
    P = [list(map(int,input().split())) for _ in range(N)]
    bit_list = list(itertools.product([0, 1], repeat=10))
    bit_list.pop(0)
    answer = -10**7-1
    for b in bit_list:
        profit = 0
        for i in range(N):
            a = 0 ## 一致してる営業時間の数
            for j in range(10):
                if b[j]==1 and F[i][j]==1:
                    a+=1
            profit+=P[i][a]

        answer = max(answer,profit)

    print(answer)
    return 

if __name__ == '__main__':
    main()

