#include <bits/stdc++.h>
int main() {
  char n;
  scanf("%d", &n);
  short f[n];
  for (int i = 0; i < n; i++) {
    f[i] = 0;
    for (int j = 0; j < 10; j++) {
      getchar();
      f[i] |= (getchar() % 2) << j;
    }
  }
  int p[n][11];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 11; j++) scanf("%d", &p[i][j]);
  int ans = -1e9;
  for (int i = 1; i < 1 << 10; i++) {
    int tmp = 0;
    for (int j = 0; j < n; j++) {
      char c = 0;
      for (short a = i & f[j]; a; a >>= 1) c += a & 1;
      tmp += p[j][c];
    }
    if (ans < tmp) ans = tmp;
  }
  printf("%d\n", ans);
  return 0;
}
