#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;
int main() {
  ll n;
  cin >> n;
  vector<vector<ll>> f(n, vector<ll>(10));
  vector<vector<ll>> p(n, vector<ll>(11));
  ll ans = -INF;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (10); ++j) cin >> f[i][j];
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (11); ++j) cin >> p[i][j];
  }
  for (int bit = 0; bit < (1 << 10); ++bit) {
    vector<int> d(n);
    for (int i = 0; i < (10); ++i)
      if (bit & (1 << i)) {
        d[i] = 1;
      }
    if (__builtin_popcount(bit) == 0) continue;
    ll sum = 0;
    for (int i = 0; i < (n); ++i) {
      ll cnt = 0;
      for (int j = 0; j < (10); ++j) {
        if (d[j] == f[i][j] && d[j] == 1) cnt++;
      }
      sum += p[i][cnt];
    }
    chmax(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
