#include <bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N;
int F[102][10];
int P[102][11];
int calc(int S) {
    long long ret = 0;
    int sum = 0;
    rep(i, N) {
        int cnt = 0;
        rep(j, 10) if ((S >> j & 1) && F[i][j]) { cnt++; }
        sum += cnt;
        ret += P[i][cnt];
        // if(S==32) printf("%d: %d, %d\n", __LINE__, cnt, P[i][cnt]);
        // cnts.push_back(cnt);
    }
    if (sum) {
        // if(S==32) cout << S << ": " << ret << ", " << sum << endl;
        return ret;
    }
    return -1e18;
}
int main() {
    cin >> N;
    rep(i, N) rep(j, 10) cin >> F[i][j];
    rep(i, N) rep(j, 11) cin >> P[i][j];
    // rep(i, N) rep(j, 10) printf("P[%d][%d] = %d\n", i, j, P[i][j]);

    long long ans = -1e18;
    rep(S, 1 << 10) if (S) {
        ans = max(ans, calc(S));
    }

    cout << ans << endl;
    return 0;
}
