#include <bits/stdc++.h>
using namespace std;
__attribute__((constructor)) void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main() {
  long long n, f[101][11], p[101][11], ans = -10000001;
  cin >> n;
  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 < (11); j++) {
      cin >> p[i][j];
    }
  }
  for (long long i = 1; i < 1 << 10; i++) {
    long long ch = 0;
    for (long long j = 0; j < (n); j++) {
      long long count = 0;
      for (long long k = 0; k < (10); k++) {
        if ((i & (1 << k)) && f[j][k]) count++;
      }
      ch += p[j][count];
    }
    if (ans < ch) ans = ch;
  }
  cout << ans << endl;
}
