#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(void) {
  int N;
  cin >> N;
  int F[N][10], P[N][11];
  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 < 11; j++) cin >> P[i][j];
  int res = -(1 << 30);
  for (int b = 1; b < (1 << 10); b++) {
    int cc = 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]) c++;
      }
      cc += P[i][c];
    }
    cout << "cc: " << cc << endl;
    if (res < cc) res = cc;
  }
  cout << res << endl;
}
