#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    if (1) {
      ios::sync_with_stdio(false);
      cin.tie(0);
    }
  }
} star;
template <typename T>
inline bool chmin(T &l, T r) {
  bool a = l > r;
  if (a) l = r;
  return a;
}
template <typename T>
inline bool chmax(T &l, T r) {
  bool a = l < r;
  if (a) l = r;
  return a;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &it : v) is >> it;
  return is;
}
int main() {
  int N;
  cin >> N;
  vector<long long> f(N, 0);
  for (int i = (0); i < (N); i++) {
    for (int j = (0); j < (10); j++) {
      int v;
      cin >> v;
      f[i] |= (v << j);
    }
  }
  vector<vector<long long> > p(N, vector<long long>(10));
  for (int i = (0); i < (N); i++)
    for (int j = (0); j < (10); j++) cin >> p[i][j];
  long long ret = -1e15;
  for (int i = (1); i < (1 << 10); i++) {
    long long sum = 0;
    for (int j = (0); j < (N); j++) {
      long long bit = i & f[j];
      sum += p[j][__builtin_popcount((int)bit)];
    }
    chmax(ret, sum);
  }
  cout << ret << endl;
  return 0;
}
