#include <bits/stdc++.h>
bool debug = true;
int N;
std::vector<int> F;
std::vector<std::vector<int> > P;
int main() {
  std::cin >> N;
  F.resize(N, 0);
  for (long i = 0; i < (N); ++i) {
    int f = 0;
    for (long j = 0; j < (10); ++j) {
      std::cin >> f;
      F[i] = F[i] | (f << (9 - j));
    }
  }
  P.resize(N, std::vector<int>(11));
  for (long i = 0; i < (N); ++i)
    for (long j = 0; j < (11); ++j) {
      std::cin >> P[i][j];
    }
  int r = (1 << 10);
  int ans = -(1e7);
  for (int i = 1; i < r; ++i) {
    int sum = 0;
    for (long j = 0; j < (N); ++j) {
      int same = (i & (r - 1)) & (F[j] & (r - 1));
      int cnt = 0;
      for (int k = 0; k < 10; ++k) {
        if (((same >> k) & 0x01) == 0x01) {
          cnt++;
        }
      }
      sum += P[j][cnt];
    }
    ans = std::max(ans, sum);
  }
  std::cout << ans << std::endl;
}
