#include <bits/stdc++.h>
using namespace std;
int S[10] = {};
void func(int b) {
  int cnt = 0;
  S[10] = {};
  while (b > 0) {
    S[cnt] = {b % 2};
    b /= 2;
    cnt++;
  }
  return;
}
int main() {
  int N;
  cin >> N;
  int F[N][10];
  int 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 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];
      }
    }
    max_total = max(max_total, total);
  }
  cout << max_total << endl;
  return 0;
}
