#include <bits/stdc++.h>
using namespace std;
using p = pair<long long, long long>;
long long dx[4] = {-1, 0, 1, 0};
long long dy[4] = {0, 1, 0, -1};
int main(void) {
  long long n;
  cin >> n;
  long long f[15][15], p[15][15];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < 10; j++) cin >> f[i][j];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j <= 10; j++) cin >> p[i][j];
  long long ans = -1e+11;
  for (long long bit = 0; bit < (1 << 10); bit++) {
    long long check = 0;
    vector<bool> all(n, false);
    for (long long i = 0; i < n; i++) {
      long long count = 0;
      for (long long j = 0; j < 10; j++) {
        if ((bit >> j) & f[i][j]) {
          count++;
          all[j] = true;
        }
      }
      check += p[i][count];
    }
    bool zero = true;
    for (long long i = 0; i < n; i++) {
      if (all[i] == true) break;
      if (i == n - 1) zero = false;
    }
    if (zero == true) ans = max(check, ans);
  }
  cout << ans << endl;
  return 0;
}
