#include <bits/stdc++.h>
using namespace std;
int buks[11];
int N;
int F[200][20];
int P[200][20];
int many[200];
int maxs, prof;
bool first = false;
void bruteforce(int a, int b) {
  if (a == 10) {
    bool ok = false;
    for (int i = 0; i < N; i++) {
      if (buks[i] == 1) ok = true;
      break;
    }
    if (ok == true) {
      for (int i = 0; i < N; i++) many[i] = 0;
      for (int i = 0; i < 10; i++) {
        if (buks[i] == 0) continue;
        for (int j = 0; j < N; j++) {
          if (F[j][i] == 1) many[j]++;
        }
      }
      int totbuk = 0;
      prof = 0;
      for (int i = 0; i < N; i++) {
        prof += P[i][many[i]];
      }
      if (first == false) {
        first = true;
        maxs = prof;
      } else if (prof > maxs)
        maxs = prof;
    }
  } else {
    for (int i = 0; i <= 1; i++) {
      buks[a] = i;
      bruteforce(a + 1, i);
    }
  }
}
int main() {
  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 < 11; j++) scanf("%d", &P[i][j]);
  }
  bruteforce(0, 0);
  printf("%d\n", maxs);
}
