#include <bits/stdc++.h>
int main() {
  int n, k, l;
  long int sum, ans = LONG_MIN;
  int f[100];
  int p[100][11];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &k);
      if (k) {
        f[i] |= (1 << j);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  for (int j = 1; j < 1024; j++) {
    sum = 0;
    for (int i = 0; i < n; i++) {
      l = f[i] & j;
      k = 0;
      for (int m = 0; m < 10; m++) {
        k += (l >> m) & 1;
      }
      sum += p[i][k];
    }
    if (sum == -1) printf("%d\n", j);
    ans = (ans > sum) ? ans : sum;
  }
  printf("%ld", ans);
  return 0;
}
