#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(j, n) for (int j = 0; j < (n); j++)

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int f[n][10];
    int p[n][11];
    rep(i, n) rep(j, 10) cin >> f[i][j];
    rep(i, n) rep(j, 11) cin >> p[i][j];
    int ans = -999999999;
    for (int bit = 1; bit < (1 << 10);bit++){//1<<10 = 1024
        int c = 0;
        rep(i,n){
            rep(j,10){
                int d = 0;
                if(f[i][j]&&(bit>>j&1))
                    d++;
            }
            c += p[i][d];
        }
        ans = max(ans, c);
    }
    cout << ans << endl;
    return 0;
}
