#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N;
  cin >> N;
  vector<bitset<10>> A(N);
  for (long long i = (long long)(0); i < (long long)(N); i++) {
    for (long long j = (long long)(0); j < (long long)(10); j++) {
      bool F;
      cin >> F;
      if (F) A[i].set(j);
    }
  }
  vector<vector<long long>> B(N, vector<long long>(11));
  for (long long i = (long long)(0); i < (long long)(N); i++) {
    for (long long j = (long long)(0); j < (long long)(11); j++) cin >> B[i][j];
  }
  long long ans = 0;
  for (long long i = (long long)(1); i < (long long)((1 << 10)); i++) {
    long long sum = 0;
    bitset<10> C(i);
    for (long long j = (long long)(1); j <= (long long)(N); j++) {
      bitset<10> D = A[j] & C;
      sum += B[j][D.count()];
    }
    ans = max(ans, sum);
  }
  cout << ans;
}
