#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);
const int INF = (int)1000000007;
const long long MOD = (long long)1000000007;
const long long INF2 = (long long)100000000000000000;
int F[100][10];
int P[100][10];
int main() {
  int n;
  cin >> n;
  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 < 10; j++) {
      cin >> P[i][j];
    }
  }
  long long ans = -1;
  for (int i = 0; i < (1 << 10); i++) {
    long long ansbuf = 0;
    for (int k = 0; k < n; k++) {
      int matchedpair = 0;
      for (int j = 0; j < 10; j++) {
        if ((i >> j) & 1) {
          if (F[k][j] == 1) {
            matchedpair++;
          }
        }
      }
      ansbuf += P[k][matchedpair];
    }
    ans = max(ans, ansbuf);
  }
  cout << ans << endl;
  return 0;
}
