import sys

import numpy as np 



I = np.array(sys.stdin.read().split(), dtype=np.int64)

n = I[0]

f = I[1:1+10*n].reshape(n, 10)

p = I[1+10*n:].reshape(n, 11)



def main():

    schedules = np.arange(1, 2**10)[:, None] >> np.arange(10) & 1



    res = f & schedules[:, None]

    res = np.sum(res, axis=2)



    res = p[np.arange(n), res]

    res = np.sum(res, axis=1)



    ans = np.amax(res)

    return ans

    

if __name__ == '__main__':

    ans = main()

    print(ans)
import sys



*I, = list(map(int, sys.stdin.read().split()))

n = I[0]

f = list(zip(*[iter(I[1:1+10*n])] * 10))

p = list(zip(*[iter(I[1+10*n:])] * 11))



def main():

    res = -float('inf')

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

        cnt = [0] * n

        for j in range(10):

            if i >> j & 1:

                for k in range(n):

                    cnt[k] += f[k][j]

        profit = 0

        for k in range(n):

            profit += p[k][cnt[k]]

        res = max(res, profit)



    return res

        

if __name__ == '__main__':

    ans = main()

    print(ans)
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n = I[0]
f = I[1 : 1 + 10 * n].reshape(n, 10)
p = I[1 + 10 * n :].reshape(n, 11)


def main():
    schedules = np.arange(1, 2**10)[:, None] >> np.arange(10) & 1
    res = f & schedules[:, None]
    res = np.sum(res, axis=2)
    res = p[np.arange(n), res]
    res = np.sum(res, axis=1)
    ans = np.amax(res)
    return ans


if __name__ == "__main__":
    ans = main()
    print(ans)

import sys

(*I,) = list(map(int, sys.stdin.read().split()))
n = I[0]
f = list(zip(*[iter(I[1 : 1 + 10 * n])] * 10))
p = list(zip(*[iter(I[1 + 10 * n :])] * 11))


def main():
    res = -float("inf")
    for i in range(1, 2**10):
        cnt = [0] * n
        for j in range(10):
            if i >> j & 1:
                for k in range(n):
                    cnt[k] += f[k][j]
        profit = 0
        for k in range(n):
            profit += p[k][cnt[k]]
        res = max(res, profit)
    return res


if __name__ == "__main__":
    ans = main()
    print(ans)

-import numpy as np -I = np.array(sys.stdin.read().split(), dtype=np.int64) +(*I,) = list(map(int, sys.stdin.read().split())) -f = I[1 : 1 + 10 * n].reshape(n, 10) -p = I[1 + 10 * n :].reshape(n, 11) +f = list(zip(*[iter(I[1 : 1 + 10 * n])] * 10)) +p = list(zip(*[iter(I[1 + 10 * n :])] * 11)) -    schedules = np.arange(1, 2**10)[:, None] >> np.arange(10) & 1 -    res = f & schedules[:, None] -    res = np.sum(res, axis=2) -    res = p[np.arange(n), res] -    res = np.sum(res, axis=1) -    ans = np.amax(res) -    return ans +    res = -float("inf") +    for i in range(1, 2**10): +        cnt = [0] * n +        for j in range(10): +            if i >> j & 1: +                for k in range(n): +                    cnt[k] += f[k][j] +        profit = 0 +        for k in range(n): +            profit += p[k][cnt[k]] +        res = max(res, profit) +    return res