#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int N; 
cin >> N; 
int F[150][15], P[150][15]; 
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 <= 10; j++){
cin >> P[i][j];
 }
}

int y = -1000000000; 
for (int bit = 1; bit < (1<<10); ++bit){
    int benefit = 0; 
for(int i = 0; i < N; i++){
  int count = 0; 
 for (int j = 0; j < 10; j++) {
if ((bit / (1<<j)) % 2 == 1) {count += F[i][9-j];
                             }
 }
   benefit += P[i][count]; 
}
   y = max(y, benefit); 
}
cout << y << endl; 
return 0;
}
