#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;
int main() {
  ll N;
  cin >> N;
  vector<ll> F[10];
  for (ll n = 0; n < N; ++n) {
    for (ll d = 0; d < 10; ++d) {
      ll f;
      cin >> f;
      if (f) {
        F[d].push_back(n);
      }
    }
  }
  vector<ll> P[100];
  for (ll n = 0; n < N; ++n) {
    for (ll d = 0; d < 11; ++d) {
      ll p;
      cin >> p;
      P[n].push_back(p);
    }
  }
  ll ans = -999999999;
  for (ll i = 1; i < (1 << 10); ++i) {
    ll c[100] = {};
    for (ll j = 0; j < 10; ++j) {
      if (i & (1 << j)) {
        for (ll k : F[j]) {
          ++c[k];
        }
      }
    }
    ll a = 0;
    for (ll j = 0; j < N; ++j) {
      a += P[j][c[j]];
    }
    ans = max(ans, a);
  }
  cout << ans << endl;
}
