#include <bits/stdc++.h>
using namespace std;
vector<char> S(10, '0');
void func(int b) {
  int cnt = 0;
  for (int i = 0; i < S.size(); i++) {
    S[i] = '0';
  }
  while (b > 0) {
    S[cnt] = '0' + b % 2;
    b /= 2;
    cnt++;
  }
  return;
}
int main() {
  int N;
  cin >> N;
  char F[N][10];
  char P[N][11];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      int a;
      cin >> a;
      F[i][j] = a - '0';
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      int b;
      cin >> b;
      P[i][j] = b - '0';
    }
  }
  int max_total = 0;
  for (int b = 1; b <= 1023; b++) {
    func(b);
    int total = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 10; j++) {
        int cnt2 = 0;
        if (S[j] == '1' && F[i][j] == '1') {
          cnt2++;
        }
        total += P[i][cnt2] - '0';
      }
    }
    max_total = max(max_total, total);
  }
  cout << max_total << endl;
  return 0;
}
