#include <bits/stdc++.h>
int main() {
  int n, res;
  scanf("%d", &n);
  int f[n][10];
  int p[n][11];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &f[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  int my = 1, resx = 0, kaisu = 0;
  int min = -100000000;
  res = min;
  for (int k = 0; k < 1023; k++) {
    resx = 0;
    for (int j = 0; j < n; j++) {
      kaisu = 0;
      for (int i = 0; i < 10; i++) {
        kaisu += (my >> i) & f[j][i];
      }
      resx += p[j][kaisu];
    }
    my++;
    if (res < resx) {
      res = resx;
    }
  }
  printf("%d\n", res);
}
