#include <bits/stdc++.h>
const long long INF = (long long)1e18;
long long MAX_N = 100;
template <typename Head>
void print(Head head) {
  std::cout << head << std::endl;
}
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
  std::cout << head << " ";
  print(tail...);
}
int main(int argc, char* argv[]) {
  long long N;
  std::cin >> N;
  std::vector<std::vector<long long> > vopen(N,
                                             std::vector<long long>(10, 0LL));
  for (long long y = 0; y < N; y++) {
    for (long long x = 0; x < 10; x++) {
      std::cin >> vopen[y][x];
    }
  }
  std::vector<std::vector<long long> > vp(N, std::vector<long long>(11, 0LL));
  for (long long y = 0; y < N; y++) {
    for (long long x = 0; x < 11; x++) {
      std::cin >> vp[y][x];
    }
  }
  long long ans = -INF;
  for (long long S = 1; S < std::pow(2, 10); S++) {
    long long state = S;
    long long open[10];
    long long i = 0;
    while (state > 0) {
      open[i] = state % 2;
      state /= 2;
      i++;
    }
    long long benefit = 0LL;
    for (long long y = 0; y < N; y++) {
      long long cnt = 0LL;
      for (long long x = 0; x < 10; x++) {
        if ((vopen[y][x] & open[x]) == 1) {
          cnt++;
        }
      }
      benefit += vp[y][cnt];
    }
    ans = std::max(ans, benefit);
  }
  print(ans);
  return 0;
}
