#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int F[N][10];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  int P[N][11];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  int result = -1000000;
  vector<int> score;
  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) and F[i][j]) {
          c++;
        }
      }
      if (result < cc) {
        result = cc;
      }
    }
  }
  cout << result << endl;
  return 0;
}
