#include <bits/stdc++.h>
using namespace std;
int bitsNum(int bits) {
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
int main() {
  int N;
  int F[123];
  int P[123][16];
  scanf("%d", &N);
  for (int i = 0; i < (N); i++) {
    F[i] = 0;
    for (int j = 0; j < (10); j++) {
      int t;
      scanf("%d", &t);
      F[i] <<= 1;
      F[i] += t;
    }
  }
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (11); j++) {
      scanf("%d", &P[i][j]);
    }
  }
  int ans = 2147483647;
  for (int i = 0; i < (1 << 10); i++) {
    if (!i) continue;
    int t = 0;
    for (int j = 0; j < (N); j++) {
      t += P[j][bitsNum(F[j] & i)];
    }
    ans = max(ans, t);
  }
  printf("%d", ans);
  return 0;
}
