#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
long long M = 10;
long long N;
long long F[111];
long long P[11][11];
signed main() {
  cin >> N;
  for (long long i = 0; i < (N); i++) {
    for (long long j = 0; j < (M); j++) {
      long long a;
      cin >> a;
      F[i] = F[i] * 2 + a;
    }
  }
  for (long long i = 0; i < (N); i++)
    for (long long j = 0; j < (M + 1); j++) cin >> P[i][j];
  long long ans = LLONG_MIN;
  for (long long i = 1; i < 1 << M; i++) {
    long long sum = 0;
    for (long long j = 0; j < (N); j++) {
      long long tmp = i & F[j];
      sum += P[j][__builtin_popcount(tmp)];
    }
    chmax(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
