#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long f[n][10], p[n][10];
  for (long long i = 0; i < (n); i++)
    for (long long j = 0; j < (10); j++) cin >> f[i][j];
  for (long long i = 0; i < (n); i++)
    for (long long j = 0; j < (10); j++) cin >> p[i][j];
  long long ans = -1000000000000000000;
  for (long long bit = 1; bit < (1 << 10); bit++) {
    long long cc = 0;
    for (long long i = 0; i < (n); i++) {
      long long c = 0;
      for (long long j = 0; j < (10); j++) {
        if (bit & (1 << j) and f[i][j] == 1) c++;
      }
      cc += p[i][c];
    }
    chmax(ans, cc);
  }
  cout << ans << '\n';
}
