#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YN(bool b) { cout << (b ? "Yes" : "No") << endl; }
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return (gcd(b, a % b));
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long f[n][10], p[n][10];
  for (long long i = 0; i < (n); ++i)
    for (long long j = 0; j < (10); ++j) cin >> f[i][j];
  for (long long i = 0; i < (n); ++i)
    for (long long j = 0; j < (11); ++j) cin >> p[i][j];
  long long ans = -(1 << 28);
  for (long long bit = 1; bit < (1 << 10); ++bit) {
    long long sum = 0;
    for (long long i = 0; i < (n); ++i) {
      long long cnt = 0;
      for (long long j = 0; j < (10); ++j) {
        if (((bit >> j) & 1) && f[i][j]) {
          cnt++;
        }
      }
      sum += p[i][cnt];
    }
    chmax(ans, sum);
  }
  cout << (ans) << endl;
  return 0;
}
