#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    int n;
    scanf ("%d",&n);
    int f[n][10],p[n][11];
    
    for (int i=0; i<n; i++){
        for (int j=0; j<10; j++){
            scanf("%d",&f[i][j]);
        }
    }
    
    for (int i=0; i<n; i++){
        for (int j=0; j<11; j++){
            scanf("%d",&p[i][j]);
        }    
    }
    
    int open[10],count,tmp,ans;
    for (int i0=0; i0<2; i0++){
        open[0]=i0;
        for (int i1=0; i1<2; i1++){
            open[1]=i1;
            for (int i2=0; i2<2; i2++){
                open[2]=i2;
                for (int i3=0; i3<2; i3++){
                    open[3]=i3;
                    for (int i4=0; i4<2; i4++){
                        open[4]=i4;
                        for (int i5=0; i5<2; i5++){
                            open[5]=i5;
                            for (int i6=0; i6<2; i6++){
                                open[6]=i6;
                                for (int i7=0; i7<2; i7++){
                                    open[7]=i7;
                                    for (int i8=0; i8<2; i8++){
                                        open[8]=i8;
                                        for (int i9=0; i9<2; i9++){
                                            open [9]=i9;
                                          
                                            if (open[0]==0 && open [1]==0 && open[2]==0 && open[3]==0 && open[4]==0 && open[5]==0 && open[6]==0 && open[7]==0 && open[8]==0 && open[9]==0){
                                            
                                            } else {
                                                tmp=0;
                                                for (int i=0; i<n; i++){
                                                    count=0;
                                                    for( int j=0; j<10; j++){
                                                        if (open[j]==f[i][j] && open[j]==1){
                                                            count++;
                                                        }
                                                    }
                                                    tmp+=p[i][count];
                                                }
                                                    if(open[0]==0 && open [1]==0 && open[2]==0 && open[3]==0 && open[4]==0 && open[5]==0 && open[6]==0 && open[7]==0 && open[8]==0 && open[9]==1){
                                                        ans=tmp;
                                                    }   else if (tmp>ans){
                                                        ans=tmp;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    printf ("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 128