#include <bits/stdc++.h>
int main() {
  int N;
  scanf("%d", &N);
  int a, i, j, f[N][10], p[N][11], sum, max = 0xffffffff;
  for (i = 0; i < N; i++)
    for (j = 0; j < 10; j++) scanf("%d", &f[i][j]);
  for (i = 0; i < N; i++)
    for (j = 0; j < 11; j++) scanf("%d", &p[i][j]);
  for (i = 1; i < 1024; i++) {
    sum = 0;
    for (j = 0; j < N; j++) {
      a = ((i % (2 << 0)) >> 0) & f[j][0] + ((i % (2 << 1)) >> 1) &
          f[j][1] + ((i % (2 << 2)) >> 2) & f[j][2] + ((i % (2 << 3)) >> 3) &
          f[j][3] + ((i % (2 << 4)) >> 4) & f[j][4] + ((i % (2 << 5)) >> 5) &
          f[j][5] + ((i % (2 << 6)) >> 6) & f[j][6] + ((i % (2 << 7)) >> 7) &
          f[j][7] + ((i % (2 << 8)) >> 8) & f[j][8] + ((i % (2 << 9)) >> 9) &
          f[j][9];
      sum += p[j][a];
    }
    if (max < sum) max = sum;
  }
  printf("%d\n", max);
}
