#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, F[100][10], P[100][11];

int main(void) {
  cin >> N;
  REP(i, 0, N) REP(j, 0, 10) cin >> F[i][j];
  REP(i, 0, N) REP(j, 0, 11) cin >> P[i][j];

  ll ans = -(1LL << 60);
  REP(s, 1, 1LL << 10) {
    ll sum = 0;
    REP(i, 0, N) {
      ll cnt = 0;
      REP(j, 0, 10) if((s & (1LL << j)) && F[i][j] == 1) cnt++;
      sum += P[i][cnt];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
