#include <bits/stdc++.h>
using ll = long long;
using namespace std;
void solve() {
  int n;
  cin >> n;
  bool f[n + 1][11];
  int p[n + 1][11];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) f[i][j] = false;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      int _f;
      cin >> _f;
      if (_f == 1) f[i][j] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 10; j++) cin >> p[i][j];
  }
  ll ans = LLONG_MIN;
  for (int bit = 1; bit < (1 << 10); bit++) {
    ll subAns = 0ll;
    vector<int> c(11, 0);
    for (int i = 1; i <= 10; i++) {
      if (bit & (1 << (i - 1))) {
        for (int j = 1; j <= n; j++) {
          if (f[j][i]) c[j]++;
        }
      }
    }
    for (int i = 1; i <= n; i++) subAns += (ll)p[i][c[i]];
    ans = max(ans, subAns);
  }
  cout << ans << "\n";
}
int main() {
  solve();
  return 0;
}
