#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chmax(T &a, T b) {
  if (a < b) a = b;
  return a < b;
}
template <typename T>
inline bool chmin(T &a, T b) {
  if (b < a) a = b;
  return b < a;
}
template <typename T>
void vdeb(T v) {
  cout << "#vdebug" << endl;
  for (auto vv : v) cout << vv << " ";
  cout << endl;
}
template <typename T1, typename T2>
void adeb(T1 arr[], T2 n) {
  cout << "#adebug" << endl;
  for (int i = 0; i <= n; i++) cout << arr[i] << " ";
  cout << endl;
}
template <typename T1>
void mdeb(T1 mp) {
  cout << "#map pair debug" << endl;
  for (auto const &m : mp) cout << m.first << " " << m.second << endl;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
void ans(bool b) { cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b) { cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long f[20][110], p[20][110];
  cin >> n;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) {
      cin >> f[j][i];
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j <= 10; j++) {
      cin >> p[j][i];
    }
  }
  long long cnt[110];
  long long res = -1e18;
  for (int bit = 0; bit < (1 << 10); bit++) {
    Fill(cnt, 0);
    bool use = false;
    for (int j = 0; j < 10; j++) {
      if (bit & 1 << j) {
        use = true;
        for (long long i = 0; i < n; i++) {
          if (f[j][i]) cnt[i]++;
        }
      }
    }
    if (!use) continue;
    long long tmp = 0;
    for (long long i = 0; i < n; i++) {
      if (cnt[i]) {
        tmp += p[cnt[i]][i];
      }
    }
    chmax(res, tmp);
  }
  cout << res << endl;
  return 0;
}
