#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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;
}
static const ll INF = 1LL << 60;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (10); ++j) cin >> f[i][j];
  vector<vector<int>> p(n, vector<int>(11));
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (11); ++j) cin >> p[i][j];
  ll ans = -1001001001;
  for (int tmp = 1; tmp < (1 << 10); tmp++) {
    bitset<10> bit = tmp;
    ll sum = 0;
    for (int i = (0); i < (n); ++i) {
      int count = 0;
      for (int j = (0); j < (10); ++j) {
        if (bit.test(j) && f[i][j] == 1) {
          count++;
        }
      }
      sum += p[i][count];
    }
    chmax(ans, sum);
  }
  cout << ans << endl;
}
