#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int N, F[10][100], P[11][100];
  cin >> N;
  for (int j(0); j < N; j++) {
    for (int i(0); i < 10; i++) {
      cin >> F[j][i];
    }
  }
  for (int j(0); j < N; j++) {
    for (int i(0); i < 11; i++) {
      cin >> P[j][i];
    }
  }
  ll ans(-1000000000000);
  for (int bit = 1; bit < (1 << 10); ++bit) {
    ll benefit(0);
    ll kosuu[100] = {0};
    for (int i = 0; i < 10; ++i) {
      if (bit & (1 << i)) {
        for (int n(0); n < N; n++) {
          if (F[n][i] == 1) kosuu[n] += 1;
        }
      }
    }
    for (int n(0); n < N; n++) {
      benefit += P[n][kosuu[n]];
    }
    ans = max(benefit, ans);
  }
  cout << ans << endl;
  return 0;
}
