#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1000000007;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void print(const std::vector<int> &v) {
  std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
  std::cout << std::endl;
}
int F[101][11];
int P[101][11];
int main() {
  int N;
  cin >> N;
  for (long long i = 0; i < (long long)N; i++) {
    for (long long j = 0; j < (long long)10; j++) {
      cin >> F[i][j];
    }
  }
  for (long long i = 0; i < (long long)N; i++) {
    for (long long j = 0; j < (long long)11; j++) {
      cin >> P[i][j];
    }
  }
  long long ans = -1000000000000000;
  for (int msk = 0; msk <= 1 << 10; msk++) {
    long long sm = 0;
    for (long long i = 0; i < (long long)N; i++) {
      int cnt = 0;
      for (long long j = 0; j < (long long)10; j++) {
        if (msk & (1 << j)) {
          if (F[i][j]) {
            cnt++;
          }
        }
      }
      sm += P[i][cnt];
    }
    ans = max(ans, sm);
  }
  cout << ans << endl;
}
