#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N;
  cin >> N;
  vector<vector<long long>> F(N, vector<long long>(10)),
      P(N, vector<long long>(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];
  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 = -100000000;
  bitset<10> x;
  for (long long i = 0; i < (long long)(1023); i++) {
    x = i + 1;
    long long a = 0;
    for (long long j = 0; j < (long long)(N); j++) {
      long long c = 0;
      for (long long k = 0; k < (long long)(10); k++)
        if (x[k] * F[j][k] == 1) c++;
      a += P[j][c];
    }
    ans = max(ans, a);
  }
  cout << ans << endl;
}
