#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string char_to_string(char val) { return string(1, val); }
int char_to_int(char val) { return val - '0'; }
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) {
    return 1;
  } else {
    return 0;
  }
}
struct edge {
  ll to, cost;
};
int main() {
  int N;
  cin >> N;
  vector<int> B(N);
  vector<vector<int>> P(N, vector<int>(11));
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    unsigned int b = 0;
    for (int k = 0, k_len = (10); k < k_len; ++k) {
      int p;
      cin >> p;
      if (p == 1) b |= (1 << k);
    }
    B[i] = b;
  }
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    for (int k = 0, k_len = (11); k < k_len; ++k) {
      cin >> P[i][k];
    }
  }
  ll ans = -pow(10, 8);
  for (int bit = 0; bit < (1 << 10); ++bit) {
    if (bit == 0) continue;
    unsigned int c;
    ll res = 0;
    for (int i = 0; i < N; ++i) {
      int cnt = 0;
      c = (bit & B[i]);
      cnt = __builtin_popcount(c);
      res += P[i][cnt];
    }
    if (ans < res) ans = res;
  }
  cout << ans << endl;
}
