#include <bits/stdc++.h>
using namespace std;
const long long INF = 1 << 29;
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];
    }
  }
  long long ans = -INF;
  for (int bit = 1; bit < (1 << 10); ++bit) {
    vector<int> ct(n);
    for (int i = 0; i < n; ++i) ct[i] = 0;
    long long res = 0;
    for (int i = 0; i < 10; ++i) {
      if (bit & (1 << i)) {
        for (int j = 0; j < n; ++j) {
          ct[j] += F[j][i];
        }
      }
    }
    for (int i = 0; i < n; ++i) res += P[i][ct[i]];
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}
