#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
const int INFTY = 1e9+1;

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

  int ans = -INFTY;
  for (int tmp=1; tmp<(1<<10); tmp++) {
    bitset<10> s(tmp);
    int sum = 0;
    rep(i,N) {
      bitset<10> t = (F[i] & s);
      sum += P[i][t.count()];
    }
    if (ans < sum) ans = sum;
  }

  cout << ans << endl;
  return 0;
}
