#include <stdio.h>
int main(void){
  int n,i,j,l,o,ky,b,k,ans=-1000000000,md[100]={},my[100][11];
  int w[10]={1,2,4,8,16,32,64,128,256,512};
  scanf("%d",&n);
  for (i=0;i<n;i++){
    for (j=0;j<10;j++){
      scanf("%d",&b);
      md[i]+=w[j]*b;
    }
  }
  for (i=0;i<n;i++){
    for (j=0;j<11;j++){
      scanf("%d",&my[i][j]);
    }
  }
  for (i=1;i<1024;i++){
    k=0;
    for (j=0;j<n;j++){
      o=i&md[j];
      ky=0;
      for (l=0;l<10;l++){
        if (o&w[l]) ky++;
      }
      k+=my[j][ky];
    }
    if (ans<k) ans=k;
  }
  printf("%d\n",ans);
  return 0;
}