#include <bits/stdc++.h>
using namespace std;
long long unsigned int N;
int main() {
  cin >> N;
  vector<vector<long long int>> F(N, vector<long long int>(10));
  vector<vector<long long int>> P(N, vector<long long int>(10));
  for (long long unsigned int i = 0; i < N; i++) {
    for (long long unsigned int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  for (long long unsigned int i = 0; i < N; i++) {
    for (long long unsigned int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  long long int ans = -1e8;
  for (unsigned i = 1; i < pow(2, 10); i++) {
    long long int p = 0;
    for (int k = 0; k < N; k++) {
      int n = 0;
      for (int j = 0; j < 10; j++) {
        n += (i >> j & F[k][j]);
      }
      p += P[k][n];
    }
    ans = max(p, ans);
  }
  cout << ans << endl;
}
