#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(110, vector<int>(12));
  vector<vector<int>> P(110, vector<int>(12));
  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 ma = -1e7;
  int ct, c;
  for (int i = 1; i < (1 << 10); i++) {
    ct = 0;
    for (int j = 0; j < N; j++) {
      c = 0;
      for (int k = 0; k < 10; k++) {
        if ((i >> k & 1) && F[j][k]) c++;
      }
      ct += P[j][c];
    }
    ma = max(ct, ma);
  }
  cout << ma << endl;
}
