#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
template <class S, class T>
istream& operator>>(istream& is, pair<S, T>& p) {
  return is >> p.first >> p.second;
}
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << p.first << " " << p.second;
}
template <class T>
void maxi(T& x, T y) {
  if (x < y) x = y;
}
template <class T>
void mini(T& x, T y) {
  if (x > y) x = y;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  VI xs(N);
  for (int i = (0); i < (N); ++i) {
    int b = 0;
    for (int i = (0); i < (10); ++i) {
      int x;
      cin >> x;
      b |= x << i;
    }
    xs[i] = b;
  }
  VVI ps(N, VI(11));
  for (int i = (0); i < (N); ++i) {
    for (int k = (0); k < (11); ++k) cin >> ps[i][k];
  }
  int ans = -1e9;
  for (int b = (1); b < ((1 << 10)); ++b) {
    int s = 0;
    VI cnt(10);
    for (int i = (0); i < (N); ++i) {
      for (int k = (0); k < (10); ++k)
        if ((b & xs[i]) >> k & 1) {
          cnt[i]++;
        }
    }
    for (int i = (0); i < (N); ++i) s += ps[i][cnt[i]];
    maxi(ans, s);
  }
  cout << ans << endl;
  return 0;
}
