#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c;
  int s = 0, t = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') t = -1;
  do {
    s = s * 10 + c - '0';
  } while (isdigit(c = getchar()));
  return s * t;
}
inline long long readl() {
  char c;
  long long s = 0;
  int t = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') t = -1;
  do {
    s = s * 10 + c - '0';
  } while (isdigit(c = getchar()));
  return s * t;
}
int ans = 0;
int n;
int d[101], f[101][101], a[101][101];
void dfs(int x) {
  if (x == 11) {
    int k = 0;
    for (int i = 1; i <= n; i++) {
      int c = 0;
      for (int j = 1; j <= 10; j++) {
        c += d[j] & f[i][j];
      }
      k += a[i][c];
    }
    ans = max(ans, k);
    return;
  }
  d[x] = 1;
  dfs(x + 1);
  d[x] = 0;
  dfs(x + 1);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 10; j++) f[i][j] = read();
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 10; j++) a[i][j] = read();
  dfs(1);
  printf("%d\n", ans);
}
