#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int F[110];
int P[110][20];

signed main()
{
    int N; cin>>N;
    REP(i,N) REP(j,10){
        int t; cin>>t;
        F[i]|=t<<j;
    }
    REP(i,N) REP(j,11) cin>>P[i][j];

    int ans=-1e18;
    for(int S=1;S<(1<<10);S++){
        int sum=0;
        REP(i,N){
            int cnt=__builtin_popcount(S&F[i]);
            sum+=P[i][cnt];
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;

}
