n = int(input())
#shopの営業データ
shopData = []
#得点ドンぐらいとれるか
point = []
for i in range(n):
    shopData.append(list(map(int, input().split())))
for i in range(n):
    point.append(list(map(int, input().split())))
#最大値
global max_point

max_point = - 10 ** 7
def searchMaxOpen(data, n):
    if n == 10:
        calcMax(data)
    else:
        data[n] = 1
        searchMaxOpen(data,n+1)
        data[n] = 0
        searchMaxOpen(data, n+1)

def calcMax(data):
    global max_point
    earnPoint = 0
    if 1 in data:
        for i in range(n):
            count = 0
            for j in range(10):
                if shopData[i][j] == data[j] and data[j] == 1:
                    count += 1
            earnPoint += point[i][count]
    else:
        return
    if earnPoint > max_point:
        max_point = earnPoint

start = [None] * 10
searchMaxOpen(start, 0)

print(max_point)