#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int f[n + 1][11];
  int i, k, j;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= 10; j++) scanf("%d", &f[i][j]);
  int p[n + 1][11];
  for (i = 1; i <= n; i++)
    for (j = 0; j <= 10; j++) scanf("%d", &p[i][j]);
  int joi[11];
  int max = -10000003;
  for (int si = 1; si <= 1023; si++) {
    i = si;
    for (j = 1; j <= 10; j++) {
      joi[j] = i % 2;
      i = i / 2;
    }
    int ans = 0;
    for (j = 1; j <= n; j++) {
      int same = 0;
      for (k = 1; k <= 10; k++) {
        if (joi[k] == 1 && f[j][k] == 1) same++;
      }
      ans += p[j][same];
    }
    if (ans > max) max = ans;
  }
  printf("%d", max);
  return 0;
}
