#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);

int main(){
    int n, tmp; sc(n)
    ll ans = -1e10;
    vector<vector<int> > f(n, vector<int>(10)), p(n, vector<int>(11));
    vector<int> cnt(n, 0);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 10; j++) sc(f[i][j])
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 11; j++) sc(p[i][j])
    }
    for (int i = 1; i < (1<<10); i++){
        tmp = 0;
        fill(cnt.begin(), cnt.end(), 0);
        for (int j = 0; j < 10; j++){
            if (!(i & (1<<j))) continue;
            for (int k = 0; k < n; k++){
                if (f[k][j] == 1) cnt[k] += 1;
            }
        }
        for (int j = 0; j < n; j++) tmp += p[j][cnt[j]];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}