#include <bits/stdc++.h>
int bothOpen(int *a, int *b) {
  int sum = 0, i;
  for (i = 0; i < 10; i++) {
    if (a[i] == b[i]) sum++;
  }
  return sum;
}
int maxProfit(int *p) {
  int i;
  int convey[10];
  int max = p[1];
  for (i = 1; i < 513; i++) {
    if (p[i] > max) max = p[i];
  }
  return max;
}
int main() {
  int n;
  int i, j;
  int a[10];
  int k, convey[10];
  int sumProfit[513];
  int p[100][11];
  int f[100][10];
  while (scanf("%d", &n) != -1) {
    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 <= 512; i++) {
      int temp = i;
      for (j = 0; j < 10; j++) {
        a[j] = temp % 2;
        temp >>= 1;
      }
      sumProfit[i] = 0;
      for (j = 0; j < n; j++) {
        for (k = 0; k < 10; k++) convey[k] = f[j][k];
        int zz = p[j][bothOpen(a, convey)];
        sumProfit[i] = sumProfit[i] + zz;
      }
    }
    printf("%d\n", maxProfit(sumProfit));
  }
}
