#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vvi o(n, vi(10));
  vvi p(n, vi(10));
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (10); ++j) cin >> o[i][j];
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (11); ++j) cin >> p[i][j];
  ll ans = -1e9;
  for (int i = (1); i < (1 << 10); ++i) {
    vi a(n);
    ll score = 0;
    for (int j = (0); j < (10); ++j) {
      if (i >> j & 1) {
        for (int k = (0); k < (n); ++k) {
          if (o[k][j]) a[k]++;
        }
      }
    }
    for (int j = (0); j < (n); ++j) {
      score += p[j][a[j]];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}
