#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int N;
    scanf("%d", &N);
    vector<vector<int> > f(N, vector<int>(10));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            scanf("%d", &f[i][j]);
        }
    }

    vector<vector<int> > p(N, vector<int>(11));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 11; j++){
            scanf("%d", &p[i][j]);
        }
    }

    int max_profit = -1e11;
    for(unsigned int i = 1; i < pow(2, 10); i++){
        int profit = 0;
        for(int j = 0; j < N; j++){
            int cnt = 0;
            for(int k = 0; k < 10; k++){
                if(i >> k & (unsigned int) 1)
                    cnt += f[j][k];
            }
            profit += p[j][cnt];
        }
        max_profit = max(max_profit, profit);
    }
    printf("%d\n", max_profit);
    return 0;
}
