#include <bits/stdc++.h>
using std::vector;
int main() {
  long long n;
  scanf("%lld", &n);
  long long open[n][10];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) {
      scanf("%lld", &open[i][j]);
    }
  }
  long long earn[n][11];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 11; j++) {
      scanf("%lld", &earn[i][j]);
    }
  }
  long long mx = -10e7;
  for (long long i = 1; i < 1024; i++) {
    long long sm = 0;
    for (long long j = 0; j < n; j++) {
      long long cnt = 0;
      for (long long k = 0; k < 10; k++) cnt += (i >> k & open[j][k]);
      sm += earn[j][cnt];
    }
    mx = sm > mx ? sm : mx;
  }
  printf("%lld\n", mx);
  return 0;
}
