#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1001001001;
const ll mod = 1000000007;
using graph = vector<vector<ll>>;
ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
bool isp(ll n) {
  bool res = true;
  if (n == 1)
    return false;
  else {
    for (ll i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        res = false;
        break;
      }
    }
    return res;
  }
}
int main() {
  ll N;
  cin >> N;
  vector<vector<bool>> yes(N, vector<bool>(10, false));
  vector<vector<ll>> num(N, vector<ll>(11));
  ll n;
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < 10; j++) {
      cin >> n;
      if (n) yes[i][j] = true;
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N; i++)
    for (ll j = 0; j < 11; j++) cin >> num[i][j];
  for (ll i = 0; i < (1 << 10) - 1; i++) {
    bool ng = false;
    ll cnt = 0;
    for (ll j = 0; j < N; j++) {
      ll m = 0;
      for (ll k = 0; k < 10; k++) {
        if ((i << k) & 1 && yes[i][j]) m++;
      }
      if (!m) {
        ng = true;
        break;
      }
      cnt += num[i][m];
    }
    if (ng) continue;
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}
