def main():

    SHOP_NUM = int(eval(input()))

    open_info = [input().split() for _ in range(SHOP_NUM)]

    profit = [list(map(int, input().split())) for _ in range(SHOP_NUM)]

    answer = -float("inf")

    for i in range(1, 1024):

        open = str(format(i, '10b'))

        now_profit = 0

        for shop in range(SHOP_NUM):

            tmp = 0

            for j in range(10):

                if open[j] == "1" and open_info[shop][j] == "1":

                    tmp += 1

            now_profit += profit[shop][tmp]

        answer = max(answer, now_profit)

    print(answer)





if __name__ == '__main__':

    main()
def main():

    n = int(eval(input()))

    f = [list(map(int, input().split())) for _ in range(n)]

    p = [list(map(int, input().split())) for _ in range(n)]

    answer = -float("inf")

    for i in range(1, pow(2, 10)):

        now = 0

        cnt = [0 for _ in range(n)]

        for j in range(10):

            if (i >> j) & 1:

                for k in range(n):

                    if f[k][j]:

                        cnt[k] += 1

        for j in range(n):

            now += p[j][cnt[j]]

        answer = max(answer, now)

    print(answer)





if __name__ == '__main__':

    main()



def main():
    SHOP_NUM = int(eval(input()))
    open_info = [input().split() for _ in range(SHOP_NUM)]
    profit = [list(map(int, input().split())) for _ in range(SHOP_NUM)]
    answer = -float("inf")
    for i in range(1, 1024):
        open = str(format(i, "10b"))
        now_profit = 0
        for shop in range(SHOP_NUM):
            tmp = 0
            for j in range(10):
                if open[j] == "1" and open_info[shop][j] == "1":
                    tmp += 1
            now_profit += profit[shop][tmp]
        answer = max(answer, now_profit)
    print(answer)


if __name__ == "__main__":
    main()

def main():
    n = int(eval(input()))
    f = [list(map(int, input().split())) for _ in range(n)]
    p = [list(map(int, input().split())) for _ in range(n)]
    answer = -float("inf")
    for i in range(1, pow(2, 10)):
        now = 0
        cnt = [0 for _ in range(n)]
        for j in range(10):
            if (i >> j) & 1:
                for k in range(n):
                    if f[k][j]:
                        cnt[k] += 1
        for j in range(n):
            now += p[j][cnt[j]]
        answer = max(answer, now)
    print(answer)


if __name__ == "__main__":
    main()

-    SHOP_NUM = int(eval(input())) -    open_info = [input().split() for _ in range(SHOP_NUM)] -    profit = [list(map(int, input().split())) for _ in range(SHOP_NUM)] +    n = int(eval(input())) +    f = [list(map(int, input().split())) for _ in range(n)] +    p = [list(map(int, input().split())) for _ in range(n)] -    for i in range(1, 1024): -        open = str(format(i, "10b")) -        now_profit = 0 -        for shop in range(SHOP_NUM): -            tmp = 0 -            for j in range(10): -                if open[j] == "1" and open_info[shop][j] == "1": -                    tmp += 1 -            now_profit += profit[shop][tmp] -        answer = max(answer, now_profit) +    for i in range(1, pow(2, 10)): +        now = 0 +        cnt = [0 for _ in range(n)] +        for j in range(10): +            if (i >> j) & 1: +                for k in range(n): +                    if f[k][j]: +                        cnt[k] += 1 +        for j in range(n): +            now += p[j][cnt[j]] +        answer = max(answer, now)