#include <iostream>
#include <algorithm>
using namespace std;

int N;
int B[100];
int C[100][11];
int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    for(int k = 0; k < 10; ++k) {
      int z;
      cin >> z;
      B[i] += (z << k);
    }
  }
  
  for(int i = 0; i < N; ++i) {
    for(int k = 0; k < 11; ++k) {
      int z;
      cin >> z;
      C[i][k] = z;
    }
  }
  
  int mx = -1000000009;
  for(int s = 1; s < 1024; ++s) {
    int sum = 0;
    for(int i = 0; i < N; ++i) {
      sum += C[i][__builtin_popcount(s & B[i])];
    }
    mx = max(mx, sum);
  }
  cout << mx << endl;
  return 0;
}
