#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int ans = 0; int N = 0;
int a[10]; int F[110][10]; int P[110][11];

void func(void){
  
  int sum = 0; 
  
  for(int i = 0; i < N; i++){
    int cnt = 0;
    for(int j = 0; j < 10; j++){
      if(a[j] == 1 && F[i][j] == 1){  cnt++;}}
      sum += P[i][cnt];}
  
  ans = max(ans,sum);}}


void dfs(int pos){ //a[10] に01列を出力する
  if(pos == 10){ func(); return;}
  a[pos] = 0; dfs(pos + 1);
  a[pos] = 1; dfs(pos + 1);}

int main(){
   cin >> N;
 
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 10; j++){
      cin >> F[i][j];}}
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 11; j++){
      cin >> P[i][j];}}
  
  dfs(0);
  
  cout << ans << endl;
  
  return 0;}


