#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> F(N);
  for (int i = 0; i < N; i++) {
    int key = 0;
    for (int j = 0; j < 5; j++) {
      for (int k = 0; k < 2; k++) {
        key <<= 1;
        int v;
        cin >> v;
        key += v;
      }
    }
    F[i] = key;
  }
  vector<vector<int>> P(N, vector<int>(10));
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 11; j++) cin >> P[i][j];
  int score_max = -100000000;
  for (int i = 1; i < 1024; i++) {
    int current = 0;
    for (int j = 0; j < N; j++) {
      int opens = i & F[j];
      bitset<sizeof(unsigned long long)> values((unsigned long long)opens);
      int k = 0;
      for (int l = 0; l < 32; l++)
        if (values[l]) k++;
      current += P[j][k];
    }
    score_max = max(score_max, current);
  }
  cout << score_max << endl;
  return 0;
}
