#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
struct io {
  io() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  };
};
const int MOD = 1000000007;
const int INF = INT_MAX;
const long long int LLINF = 1LL << 60;
int main(void) {
  int n;
  cin >> n;
  vector<vector<int> > f(n, vector<int>(10));
  vector<vector<int> > p(n, vector<int>(10));
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (10); ++j) cin >> f[i][j];
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (11); ++j) cin >> p[i][j];
  int bit = 1;
  long long int ans = -INF;
  while (bit < pow(2, 10)) {
    long long int tmpans = 0;
    int t = bit;
    vector<int> open(10, 0);
    int pos = 0;
    while (t > 0) {
      open[pos] = t % 2;
      t /= 2;
      pos++;
    }
    for (int i = 0; i < n; i++) {
      int match = 0;
      for (int j = 0; j < 10; j++) {
        if (f[i][j] == open[j] && f[i][j] == 1) {
          match++;
        }
      }
      tmpans += p[i][match];
    }
    ans = max(ans, tmpans);
    bit++;
  }
  cout << (ans) << endl;
}
