#include <iostream>
#include <climits>
using namespace std;
const int N_MAX = 100;
const ll INF = INT_MAX / 3;
int N;
int F[N_MAX][10];
ll P[N_MAX][11];
int O[10];
ll ans = - INF;
void dfs(int i) {
    if (i >= 10) {
        int cnt = 0;
        for (int j = 0; j < 10; j++) {
            if (O[j]) {
                cnt++;
            }
        }
        if (cnt != 0) {
            ll sum = 0;
            for (int j = 0; j < N; j++) {
                cnt = 0;
                for (int k = 0; k < 10; k++) {
                    if (O[k] == 1 && O[k] == F[j][k]) {
                        cnt++;
                    }
                }
                sum += P[j][cnt];
            }
            ans = max(ans, sum);
        }
    } else {
        O[i] = 0;
        dfs(i + 1);
        O[i] = 1;
        dfs(i + 1);
    }
}
int main (void) {
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> F[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> P[i][j];
        }
    }

    dfs(0);

    cout << ans << endl;

    return 0;
}
