#include <bits/stdc++.h>
using namespace std;
int main() {
  int s[15], n, m, o, a[150][20], b[150][20], i, j, k, l, u, sum = 0,
                                                             max = -100000000;
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= 10; j++) scanf("%d", &a[i][j]);
  for (i = 1; i <= n; i++)
    for (j = 0; j < 11; j++) scanf("%d", &b[i][j]);
  for (i = 1; i <= 1023; i++) {
    int p[150] = {0};
    m = i;
    o = 1;
    while (m) {
      s[o++] = m % 2;
      m /= 2;
    }
    for (j = o; j <= 10; j++) s[j] = 0;
    for (k = 1; k <= 10; k++) {
      if (s[k] == 1) {
        for (l = 1; l <= n; l++) {
          if (a[l][k] == 1) p[l]++;
        }
      }
    }
    sum = 0;
    for (u = 1; u <= n; u++) sum += b[u][p[u]];
    if (sum > max) max = sum;
  }
  printf("%d\n", max);
}
