#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<vector<long long>> f(n, vector<long long>(10));
  vector<vector<long long>> p(n, vector<long long>(11));
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < 10; j++) cin >> f[i][j];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < 11; j++) cin >> p[i][j];
  long long ret = -1000000000ll * 1000000000ll;
  for (long long bit = 0; bit < 1 << 10; bit++) {
    if (bit == 0) continue;
    long long buf = bit;
    vector<bool> used(n, false);
    for (long long i = 0; i < 10; i++) {
      if (buf % 2) used[i] = true;
      buf /= 2;
    }
    long long adv = 0;
    vector<long long> c(n);
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < 10; j++) {
        if (used[i] && f[i][j]) c[i]++;
      }
    }
    for (long long i = 0; i < n; i++) {
      adv += p[i][c[i]];
    }
    ret = max(ret, adv);
  }
  cout << ret << endl;
}
