#include <bits/stdc++.h>
using namespace std;
int count_b(int num) {
  int ret = 0;
  while (num > 0) {
    int mod = num % 2;
    num = (num - mod) / 2;
    ret += mod;
  }
  return ret;
}
int main() {
  int f[100], p[100][11], n, fi;
  long sale, res = -10000000;
  scanf("%d", &n);
  fill_n(f, n, 0);
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (10); j++) {
      scanf("%d", &fi);
      if (fi) f[i] += (1 << j);
    }
  }
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (11); j++) scanf("%d", &(p[i][j]));
  }
  for (int mask = 1; mask < (1 << 10); mask++) {
    sale = 0;
    for (int i = 0; i < (n); i++) {
      sale += p[i][count_b(f[i] & mask)];
    }
    res = max(res, sale);
  }
  printf("%ld", res);
  return 0;
}
