#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vec = vector<ll>;
using Graph = vector<vector<ll>>;
int main() {
  cout << fixed << setprecision(16);
  ll n;
  cin >> n;
  ll f[n][10];
  ll p[n][11];
  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];
    }
  }
  ll count = 0;
  ll sum = 0;
  ll ans = -999999999ll;
  for (ll bit = (1 << 0); bit < (1 << 10); bit++) {
    sum = 0;
    for (ll j = 0; j < n; j++) {
      count = 0;
      for (ll k = 0; k < 10; k++) {
        if (bit & (1 << k)) {
          if (f[j][k]) count++;
        }
      }
      sum += p[j][count];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
