#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int F[105][15];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  int P[105][15];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  int total[100000];
  int maxtotal = -9999999;
  for (int i = 1; i < (1 << 10); i++) {
    total[i] = 0;
    for (int j = 0; j < N; j++) {
      int counter = 0;
      for (int k = 0; k < 10; k++) {
        if ((i & (1 << k)) && F[j][k]) {
          counter++;
        }
      }
      total[i] += P[j][counter];
    }
    maxtotal = max(total[i], maxtotal);
  }
  cout << maxtotal << endl;
  return 0;
}
