#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long f[100][11] = {};
  for (long long i = 0; i < (long long)(n); i++) {
    for (long long j = 0; j < (long long)(10); j++) cin >> f[i][j];
  }
  long long p[100][11] = {};
  for (long long i = 0; i < (long long)(n); i++) {
    for (long long j = 0; j < (long long)(11); j++) cin >> p[i][j];
  }
  long long ans = -1e10;
  for (long long bit = 1; bit < (1 << 10); bit++) {
    long long sum = 0, cnt = 0;
    for (long long i = 0; i < (long long)(n); i++) {
      cnt = 0;
      for (long long b = 0; b < (long long)(10); b++)
        if ((i >> b & 1) && f[i][b]) cnt++;
      sum += p[i][cnt];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
