#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (ll i = (0); i < (n); ++i) {
    for (ll j = (0); j < (10); ++j) {
      cin >> f[i][j];
    }
  }
  vector<vector<ll>> p(n, vector<ll>(11));
  for (ll i = (0); i < (n); ++i) {
    for (ll j = (0); j < (11); ++j) {
      cin >> p[i][j];
    }
  }
  ll ans = -1e7;
  for (ll i = (1); i < (1024); ++i) {
    ll P = 0;
    bitset<10> open(i);
    for (ll j = (0); j < (n); ++j) {
      int c = 0;
      for (ll k = (0); k < (10); ++k) {
        if (open[k] && f[j][k]) c++;
      }
      P += p[j][c];
    }
    ans = max(ans, P);
  }
  cout << ans << endl;
  return 0;
}
