#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main(void) {
  int n;
  int f[100][10];
  long long p[100][10];
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (10); ++j) {
      int v;
      cin >> v;
      f[i][j] = v;
    }
  }
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (11); ++j) {
      long long v;
      cin >> v;
      p[i][j] = v;
    }
  }
  long long ans = -1000000000000;
  for (int b = 1; b < (1 << 10); b++) {
    long long x = 0;
    for (int i = (0); i < (n); ++i) {
      int c = 0;
      for (int j = (0); j < (10); ++j) {
        if ((b >> j & 1) && f[i][j] == 1) c++;
      }
      x += p[n - i - 1][c];
    }
    if (x > ans) {
      ans = x;
      cerr << "b"
           << " = " << (b) << " (L" << 86 << ")"
           << " "
           << "<stdin>" << endl;
      ;
      cerr << "x"
           << " = " << (x) << " (L" << 87 << ")"
           << " "
           << "<stdin>" << endl;
      ;
    }
  }
  cout << ans << endl;
  return 0;
}
