#include <bits/stdc++.h>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long long gf = 1e6 + 9;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  long long n;
  cin >> n;
  map<pair<long long, long long>, long long> m1;
  long long f[n][10];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) {
      long long x;
      cin >> x;
      f[i][j] = x;
    }
  }
  long long p[n][10];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 11; j++) cin >> p[i][j];
  }
  long long ans = -(1e18 + 5);
  for (long long mask = 1; mask < (1 << 10ll); mask++) {
    map<long long, long long> m;
    long long cnt = 0;
    for (long long i = 0; i < 10; i++) {
      if (mask & (1 << i)) {
        cnt++;
        for (long long j = 0; j < n; j++) {
          if (f[j][i]) m[j]++;
        }
      }
    }
    if (cnt == 10) {
      ;
    }
    if ((long long)m.size() == 0) continue;
    long long var = 0;
    for (long long i = 0; i < n; i++) {
      long long x = m[i];
      var += p[i][x];
    }
    ans = max(ans, var);
  }
  cout << ans << '\n';
  return 0;
}
