#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 100;
const int kInf = 1000000000;
int N;
int F[kMaxN][10];
int P[kMaxN][11];
int ans = -kInf;
bool opened = false;
void Bfs(int j, vector<int> c) {
  if (j < 10) {
    Bfs(j + 1, c);
    opened = true;
    vector<int> c2(c);
    for (int i = 0; i < N; ++i) {
      if (F[i][j]) {
        ++c2[i];
      }
    }
    Bfs(j + 1, c2);
    opened = false;
  } else if (opened) {
    int ans2 = 0;
    ans = max(ans, ans2);
  }
  return;
}
int main() {
  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 < 11; ++j) {
      cin >> P[i][j];
    }
  }
  vector<int> c(10, 0);
  Bfs(0, c);
  cout << ans << endl;
  return 0;
}
