#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
int BitCount(int64_t x) {
  x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
  x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
  x = (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4 & 0x0f0f0f0f0f0f0f0f);
  x = (x & 0x00ff00ff00ff00ff) + (x >> 8 & 0x00ff00ff00ff00ff);
  x = (x & 0x0000ffff0000ffff) + (x >> 16 & 0x0000ffff0000ffff);
  x = (x & 0x00000000ffffffff) + (x >> 32 & 0x00000000ffffffff);
  return (int)(x);
}
int main() {
  int N;
  cin >> N;
  int F[1000];
  int P[100][100];
  for (int i = 0; i < N; i++) {
    int t;
    F[i] = 0;
    for (int j = 0; j < 10; j++) {
      cin >> t;
      F[i] |= t << j;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  int64_t ans = -INF;
  for (int i = 1; i < 1024; i++) {
    int64_t prof = 0;
    if (BitCount(i) == 0) continue;
    for (int j = 0; j < N; j++) {
      prof += P[j][BitCount(i & F[j])];
    }
    ans = max(prof, ans);
  }
  cout << ans << endl;
  return 0;
}
