#include <bits/stdc++.h>
using ll = long long;
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;
}
const long long INFLL = 1LL << 62;
const int INF = 1 << 30;
const double PI = acos(-1);
int main() {
  int n;
  int ans = -INF;
  cin >> n;
  vector<int> hash(n, 0);
  vector<vector<int>> pro(n, vector<int>(12, 0));
  int bef;
  for (int i = 0, i_len = (int)(n); i < i_len; i++) {
    for (int j = 0, j_len = (int)(10); j < j_len; j++) {
      cin >> bef;
      hash[i] |= ((bef) << j);
    }
  }
  for (int i = 0, i_len = (int)(n); i < i_len; i++) {
    for (int j = 0, j_len = (int)(11); j < j_len; j++) {
      cin >> pro[i][j];
    }
  }
  int cnt = 0;
  int tmp = 0;
  for (int bit = 1; bit < (1 << 11); bit++) {
    cnt = 0;
    for (int i = 0; i < n; i++) {
      tmp = bit & hash[i];
      cnt += pro[i][__builtin_popcount(tmp)];
    }
    chmax(ans, cnt);
  }
  cout << ans << endl;
}
