# coding: utf-8

II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    N = II()
    F = [tuple(MI()) for _ in range(N)]
    P = [tuple(MI()) for _ in range(N)]
    TS = 10

    answers = []
    for tt in range(1, 2**TS):
        ts_open = [False] * TS
        for i, c in enumerate(bin(tt)[2:]):
            ts_open[i] = (c == "1")
        a = 0
        for i in range(N):
            o = 0
            for j in range(TS):
                if ts_open[j] and F[i][j] == 1: o += 1
            a += P[i][o]
        answers.append(a)
    return max(answers)


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