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

int main() {
  int N; cin >> N;
  int F[N][10]; for (int i=0; i<N; i++) for (int j=0; j<10; j++) cin >> F[i][j];
  int P[N][11]; for (int i=0; i<N; i++) for (int j=0; j<11; j++) cin >> P[i][j];

  int result = -1 * pow(2,31);
  for (int bit=1; bit<(1<<10); bit++) {
    int sum = 0;
    for (int i=0; i<N; i++) {
      int x = 0;
      for (int j=0; j<10; j++) { if ( bit & (1<<j) && F[i][j] == 1 ) x += 1; }
      sum += P[i][x];
    }
    if (result<sum) result = sum;
  }
  cout << result << endl;
  return 0;
}