#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
istream& operator>>(istream& s, vector<T>& v) {
  for (T& x : v) {
    s >> x;
  }
  return s;
}
template <class T>
void cout_v(const vector<T>& c) {
  for (int i = 0; i < c.size(); i++) cout << c[i] << endl;
}
template <class T>
void cout_h(const vector<T>& c) {
  for (int i = 0; i < c.size(); i++)
    cout << c[i] << (i == c.size() - 1 ? "\n" : " ");
}
template <class T>
inline bool chmin(T& a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
inline bool chmax(T& a, T b) {
  return a < b ? a = b, true : false;
}
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<vector<ll>> F(N, vector<ll>(10));
  cin >> F;
  vector<vector<ll>> P(N, vector<ll>(11));
  cin >> P;
  ll ans = LLONG_MIN;
  for (int i = 1; i < ((1 << 10) - 1); i++) {
    vector<ll> c(N, 0);
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < 10; k++) {
        if (F[j][k] && (i & (1 << k))) {
          c[j]++;
        }
      }
    }
    ll profit = 0;
    for (int j = 0; j < N; j++) {
      profit += P[j][c[j]];
    }
    chmax(ans, profit);
  }
  cout << ans << endl;
}
