#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int N;
    scanf("%d",&N);
    int F[N];
    for(int i=0;i<N;i++)F[i]=0;
    for(int i=0;i<N;i++)for(int j=0;j<10;j++){int kari;scanf("%d",&kari);F[i]*=2;F[i]+=kari;}
    int P[N][11];
    for(int i=0;i<N;i++)for(int j=0;j<11;j++)scanf("%d",&P[i][j]);
    int ans=-1000000007;
    for(int i=1;i<(1<<10);i++){
        int karians=0;
        for(int j=0;j<N;j++){
            karians+=P[j][__builtin_popcount(i&F[j])];
        }
        if(ans<karians)ans=karians;
    }
    printf("%d",ans);
    return 0;
}
