#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,n,a) for (int i = n - 1; i >= a; i--)
using namespace std;

int N,F [100][14],P [100][15];
int main () {
    scanf("% d", &N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) scanf("% d", &F[i][j]);
    }
    for (int i = 0; i < N; i++) for (int j = 0; j < 11; j++) scanf("%d", &P[i][j]);
    int res = -(1 < < 30);
    for (int b = 1; b < (1 < < 10); b++) {
        int cc = 0;
        for (int i = 0; i < N; i++) {
            int c = 0;
            for (int j = 0; j < 10; j++) if ((b >> j & 1) && F[i][j])c++;
            cc += P[i][c];
        }
        if (res < cc)res = cc;
    }
    printf("%d\n", res);
}