#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll LINF = 0x1fffffffffffffff;
const vector<ll> four = {0, 1, 0, -1, 0};
using tuplis = pair<ll, pair<ll, ll>>;
template <class T>
using pq = priority_queue<T, vector<T>, greater<T>>;
template <class T>
inline constexpr bool update_min(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline constexpr bool update_max(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
signed main() {
  int n;
  cin >> n;
  vector<int> bits(10);
  vector<vector<ll>> f(n, vector<ll>(10)), p(n, vector<ll>(11));
  ll ans = -100000000;
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j < 10; j++) bits[i] |= (f[i][j] << (9 - j));
  for (ll bit = 1; bit < 1 << 10; bit++) {
    ll cnt = 0;
    for (ll i = 0; i < n; i++) {
      ll k = bit;
      k &= bits[i];
      cnt += p[i][__builtin_popcount(k)];
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}
