#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<vector<long long>> f(n, vector<long long>(11)),
      p(n, vector<long long>(11));
  for (int i = 0; i < ((int)n); i++) {
    for (int j = 0; j < ((int)10); j++) cin >> f[i][j];
  }
  for (int i = 0; i < ((int)n); i++) {
    for (int j = 0; j < ((int)11); j++) cin >> p[i][j];
  }
  long long maxsum = -11451419;
  for (int bit = 1; bit < ((int)(1 << 10)); bit++) {
    vector<long long> count(n, 0);
    for (int j = 0; j < ((int)10); j++) {
      for (int i = 0; i < ((int)n); i++) {
        if (bit & (f[i][j] << j)) count[i]++;
      }
    }
    long long tmpsum = 0;
    for (int i = 0; i < ((int)n); i++) tmpsum += p[i][count[i]];
    maxsum = max(tmpsum, maxsum);
  }
  cout << maxsum << endl;
}
