#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int N;
int F[100][10];
int P[100][20];
int mi[20];
long long int admi = -100000000;
long long int culu(){
    long long int ans = 0;
    int kabu[N] = {0};
    bool result = true;
    for(int a = 0;a < 10;a++){
        if(mi[a] == 1)result = false;
    }
    if(result)return -100000000;
    for(int a = 0;a < 10;a++){
        if(mi[a] == 1){
            for(int b = 0;b < N;b++){
                if(F[b][a] == 1){
                    kabu[b]++;
                }
            }
        }
    }
    for(int a = 0;a < N;a++){
        ans += P[a][kabu[a]];
    }
    return ans;
}
long long int func(int i){
    if(i == 10){
        admi = max(admi,culu());
        return admi;
    }
    mi[i] = 0;func(i+1);
    mi[i] = 1;func(i+1);
}
int main()
{
    cin >> N;
    for(int a = 0;a < N;a++){
        for(int b = 0;b < 10;b++){
            cin >> F[a][b];
        }
    }
    for(int a = 0;a < N;a++){
        for(int b = 0;b < 11;b++){
            cin >> P[a][b];
        }
    }
    cout<<func(0)<<endl;
    return 0;
}
