#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
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>(10));
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (11); j++) cin >> p[i][j];
  ll ans = -INF;
  for (int bit = 1; bit < (1 << 10); ++bit) {
    vector<int> cnt(n, 0);
    for (int i = 0; i < 10; ++i) {
      if (bit & (1 << i)) {
        for (int j = 0; j < n; ++j) {
          if (f[j][i]) cnt[j]++;
        }
      }
    }
    ll tmp = 0;
    for (int i = 0; i < n; i++) {
      tmp += p[i][cnt[i]];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
