#include <bits/stdc++.h>

#define REP(i,a,b) for(int i=a;i<(b);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int N;
int F[111][22];
int P[111][13];

int main() {
  cin >> N;
  rep(i, N) rep(j, 10) {
    cin >> F[i][j];
  }
  rep(i, N) rep(j, 11) {
    cin >> P[i][j];
  }

  int64_t ans = -(1LL<<60);
  REP(S, 1, 1<<10) {
    int64_t cand = 0;
    rep(i, N) {
      int C = 0;
      rep(k, 10) {
        if ((S >> k & 1) && F[i][k]) { C++; }
      }
      cand += P[i][C];
    }
    ans = max(ans, cand);
  }
  cout << ans << endl;
}
