#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; cin >> n;
    bool F[n][10];
    int P[n][11];
    rep(i,0,n){
       rep(j,0,10){
           cin >> F[i][j];
       }
    }
    rep(i,0,n){
       rep(j,0,11){
           cin >> P[i][j];
       }
    }
    ll ans = -1e9+5;
    rep(bit,1,(1<<10)){
        int cnt[n] = {};
        ll calc=0;
        rep(shift,0,10){
            if(bit & (1<<shift)){
                rep(i,0,n){
                    if(F[i][shift])cnt[i]++;
                }
            }
        }
        rep(i,0,n){
           calc += P [i][cnt[i]];
        }
        ans = max(ans,calc);
    }
    cout << ans << endl;
}