#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, n;
  cin >> N;
  int F[N][10];
  int P[N][10];
  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];
    }
  }
  int max = -(1 << 27);
  for (int bin = 1; bin < (1 << 10); ++bin) {
    int sum = 0;
    for (int i = 0; i < N; ++i) {
      int count = 0;
      for (int j = 0; j < 10; ++j) {
        if ((bin >> j & 1) && F[i][j]) ++count;
      }
      sum += P[i][count];
    }
    if (max < sum) max = sum;
  }
  cout << max << endl;
}
