#include <bits/stdc++.h>
int main() {
  int i, j, n, m, t, p, max = -10000001, day[101][10], money[101][11], bit[10];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    for (j = 0; j < 10; j++) scanf("%d", &day[i][j]);
  for (i = 0; i < n; i++)
    for (j = 0; j < 11; j++) scanf("%d", &money[i][j]);
  for (int i = 1; i < 1024; i++) {
    int t = i;
    int len = 0;
    for (int j = 0; j < 10; j++) {
      bit[len++] = t % 2;
      t = t / 2;
    }
    int m = 0;
    int sum = 0;
    for (t = 0; t < n; t++) {
      m = 0;
      for (p = 0; p < 10; p++)
        if (bit[p] == 1 && day[t][p] == 1) {
          m++;
        }
      sum += money[t][m];
    }
    if (sum > max) max = sum;
  }
  printf("%d", max);
  return 0;
}
