#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INF = 2e18;
long long N, M, K, C;
long long a, b, c, d;
string s;
long long f[100][10];
long long p[100][10];
int main() {
  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 <= 10; j++) {
      cin >> p[i][j];
    }
  }
  long long ans = -INF;
  for (long long i = 1; i < (1 << 10); i++) {
    long long tmp = 0;
    for (long long k = 0; k < N; k++) {
      long long cnt = 0;
      for (long long j = 0; j < 10; j++) {
        if (i & (f[k][j] << j)) {
          cnt++;
        }
      }
      tmp += p[k][cnt];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
