#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long pc(long long a) {
  long long res = 0;
  while (a > 0) {
    res += a % 2;
    a /= 2;
  }
  return res;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N, 0);
  vector<vector<long long> > B(N, vector<long long>(11));
  long long res = 0;
  long long a;
  for (long long i = 0; i < N; i++) {
    A[i] = 0;
    for (long long j = 0; j < 10; j++) {
      cin >> a;
      A[i] += a;
      A[i] *= 2;
    }
    A[i] /= 2;
  }
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < 11; j++) {
      cin >> B[i][j];
    }
  }
  res = -100000000;
  long long sum = 0;
  for (long long i = 1; i < ((long long)1 << 10); i++) {
    sum = 0;
    for (long long j = 0; j < N; j++) {
      sum += B[j][pc(i & A[j])];
    }
    res = max(res, sum);
  }
  cout << res << endl;
}
