#include <bits/stdc++.h>
using namespace std;
long F[101][10];
long P[101][11];
long overlap[101];
int main() {
  long N;
  long ans = -10e10;
  cin >> N;
  for (long i = 1; i <= N; i++) {
    for (long j = 0; j < 10; j++) cin >> F[i][j];
  }
  for (long i = 1; i <= N; i++) {
    for (long j = 0; j < 11; j++) cin >> P[i][j];
  }
  for (long i = 1; i < (1 << 10); i++) {
    for (long j = 1; j <= 10; j++) overlap[j] = 0;
    long benf = 0;
    for (long j = 0; j < 10; j++) {
      if (i & (1 << j)) {
        for (long k = 1; k <= N; k++) {
          if (F[k][j]) overlap[k]++;
        }
      }
    }
    for (long k = 1; k <= N; k++) {
      benf += P[k][overlap[k]];
    }
    ans = max(ans, benf);
  }
  cout << ans << endl;
  return 0;
}
