#include <bits/stdc++.h>
using namespace std;
#define REP(i,f,n) for(int i=f;i<(n);i++)
int n,t,ans=-1000000001,f[101],p[101][11];
int main() {
    int n;
    cin>>n;
    REP(i,0,n)
        REP(j,0,10) {
            cin>>t;
            f[i]|=t<<j;
        }
    REP(i,0,n) REP(j,0,11) cin>>p[i][j];
    REP(i,1,1<<10) {
        t=0;
        REP(j,0,n) t+=p[j][__builtin_popcount(f[j]&i)];
        if(ans<t) ans=t;
    }
    cout<<ans<<endl;
    return 0;
}

