#include <bits/stdc++.h>
int F[110][10];
int P[110][10];
int gg[10];
int min = -0x1f1f1f1f;
int my_max(int a, int b) { return a > b ? a : b; }
void dfs(int now, int N) {
  if (now == 10) {
    int flag = 0;
    for (int p = 0; p < 10; p++) flag |= gg[p];
    if (!flag) return;
    int sum = 0;
    for (int i = 0; i < N; i++) {
      int pp = 0;
      for (int k = 0; k < 10; k++)
        if (gg[k] == F[i][k] && gg[k] == 1) pp++;
      sum += P[i][pp];
    }
    min = my_max(sum, min);
  } else {
    gg[now] = 0;
    dfs(now + 1, N);
    gg[now] = 1;
    dfs(now + 1, N);
  }
}
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
    for (int k = 0; k < 10; k++) scanf("%d", &F[i][k]);
  for (int i = 0; i < N; i++)
    for (int k = 0; k <= 10; k++) scanf("%d", &P[i][k]);
  dfs(0, N);
  printf("%d\n", min);
  return 0;
}
