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