#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for (int i=a; i<(b);++i)
const int INF = 1e9;

int N;
int F[100][10];
int P[100][11];
int main(){
    cin >> N;
    REP(i,N) REP(j,10) cin >> F[i][j];
    REP(i,N) REP(j,11) cin >> P[i][j];
    int ans = -INF;
    rep(bit,1,1<<10){
        int tmp = 0;
        REP(n,N){
            int cnt = 0;
            REP(i,10){
                if((bit & (1<<i)) && F[n][i]==1) ++cnt;
            }
            tmp += P[n][cnt];
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;
}