#include <bits/stdc++.h>
int main() {
  int n, f[100][10], p[100][10];
  int max, dup, tmp;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) scanf("%d", &f[i][j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) scanf("%d", &p[i][j]);
  max = -1e9;
  for (int i = 1; i < 1 << 10; i++) {
    tmp = 0;
    for (int j = 0; j < n; j++) {
      dup = 0;
      for (int k = 0; k < 10; k++) {
        if ((i >> k & 1) & f[j][k]) dup++;
      }
      tmp += p[j][dup];
    }
    if (max < tmp) max = tmp;
  }
  printf("%d", max);
  return 0;
}
