#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-14;
template <class T>
using vec = vector<T>;
using ll = long long;
using ull = unsigned long long;
using vi = vec<int>;
using vl = vec<ll>;
using vd = vec<double>;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using vec2 = complex<double>;
template <class T = int>
inline T in() {
  T x;
  cin >> x;
  return x;
}
template <class T = int>
inline vec<T> in(int n) {
  vec<T> v(n);
  for (int i = (int)(0); i < (int)(n); ++i) v[i] = in<T>();
  return v;
}
template <class T = int>
inline void in(T* x, int n) {
  for (int i = (int)(0); i < (int)(n); ++i) x[i] = in<T>();
}
template <class T>
inline void print(const T& x) {
  cout << x << '\n';
}
template <class T>
inline void printd(const T& x, int d) {
  cout << fixed << setprecision(d) << x << '\n';
}
template <class T>
inline void printv(vec<T>& v) {
  int n = (v).size();
  for (int i = (int)(0); i < (int)(n); ++i) cout << v[i] << "\n "[i < n - 1];
}
template <class T>
inline void printv(vec<T>& v, int n) {
  for (int i = (int)(0); i < (int)(n); ++i) cout << v[i] << "\n "[i < n - 1];
}
template <class T>
inline void printa(T* ary, int n) {
  for (int i = (int)(0); i < (int)(n); ++i) cout << ary[i] << "\n "[i < n - 1];
}
bool f[128][16];
int p[128][16];
int n;
int max_profit(vec<bool>& open, int t) {
  if (t == 11) {
    vi cnt(10, 0);
    bool full_close = true;
    for (int j = (int)(0); j < (int)(10); ++j) {
      if (not open[j]) {
        continue;
      }
      for (int i = (int)(0); i < (int)(n); ++i) {
        if (f[i][j]) {
          cnt[i] += f[i][j];
          full_close = false;
        }
      }
    }
    int sum = 0;
    for (int i = (int)(0); i < (int)(10); ++i) {
      sum += p[i][cnt[i]];
    }
    return full_close ? -INF : sum;
  }
  open[t] = true;
  int tsum = max_profit(open, t + 1);
  open[t] = false;
  int fsum = max_profit(open, t + 1);
  return max(tsum, fsum);
}
signed main() {
  n = in();
  for (int i = (int)(0); i < (int)(n); ++i) {
    for (int j = (int)(0); j < (int)(10); ++j) {
      f[i][j] = in();
    }
  }
  for (int i = (int)(0); i < (int)(n); ++i) {
    for (int j = (int)(0); j < (int)(11); ++j) {
      p[i][j] = in();
    }
  }
  vec<bool> open(10, false);
  print(max_profit(open, 0));
  return 0;
}
