#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long n;
  cin >> n;
  vector<vector<long>> f(n, vector<long>(10));
  for (auto &l : f)
    for (auto &e : l) cin >> e;
  vector<vector<long>> p(n, vector<long>(10));
  for (auto &l : p)
    for (auto &e : l) cin >> e;
  long r = -1e13;
  for (long i = 1; i < 1 << 10; i++) {
    long rr = 0;
    for (long j = 0; j < n; j++) {
      long c = 0;
      for (long k = 0; k < 10; k++)
        if (f[j][k] && ((i >> k) & 1)) c++;
      rr += p[j][c];
    }
    r = max(r, rr);
  }
  cout << r << endl;
}
