#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
void solve() {}
int main() {
  int N;
  cin >> N;
  int F[N][15];
  int P[N][15];
  for (int i = 0; i < N; i++) {
    for (int k = 0; k < 10; k++) {
      cin >> F[i][k];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int k = 0; k < 11; k++) {
      cin >> P[i][k];
    }
  }
  int res = -(1 << 30);
  for (int i = 1; i < (1 << 10); i++) {
    int cc = 0;
    for (int k = 0; k < N; k++) {
      int c = 0;
      for (int p = 0; p < 10; p++) {
        if ((i >> p & 1) && F[k][p]) c++;
      }
      cc += P[k][c];
      res = max(res, cc);
    }
  }
  cout << res << endl;
  return 0;
}
