#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<vector<long long> > F(100, vector<long long>(10));
  for (int i = 0; i < (N); i++)
    for (int j = 0; j < (10); j++) cin >> F[i][j];
  vector<vector<long long> > P(100, vector<long long>(11));
  for (int i = 0; i < (N); i++)
    for (int j = 0; j < (11); j++) cin >> P[i][j];
  long long ans = -1001001001;
  for (int i = 0; i < (1 << 10); i++) {
    if (i) {
      vector<long long> B(10);
      for (int j = 0; j < (10); j++) B[j] = (i >> j) & 1;
      vector<long long> C(10);
      long long tmp = 0;
      for (int j = 0; j < (N); j++) tmp += P[j][C[j]];
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
}
