#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;
using namespace std;

typedef vector<vector<int>> vii;


int main(){
    int N;
    cin >> N;
    vector<bitset<10>> fs = vector<bitset<10>> (N, bitset<10> (0));
    vector<vector<int>> ps = vector<vector<int>> (N, vector<int> (10 + 1));
    rep(i, N){
        rep(j, 10){
            int tmp;
            cin >> tmp;
            if(tmp){
                fs[i].set(j);
            }
        }

    }

    rep(i, N){
        rep(j, 10 + 1){
            int tmp;
            cin >> tmp;
            ps[i][j] = tmp;
        }
    }

    int max_p = (1 << 10) - 1;
    ll ans = -1e10;
    for(int i = 1; i =< max_p; i++){
        bitset<10> tmp(i);
        ll  sum = 0;
        rep(j, N){
            int size = (fs[j] & tmp).count();
            //bit_set<size>でsizeが定数なりで型が同じでないとつかえない.
            sum += ps[j][size];
        }
        ans = max(sum, ans);
    }

    cout << ans << endl;

    return 0;
}
