#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<vector<long long> > f(n, vector<long long>(10));
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < 10; j++) cin >> f[i][j];
  vector<vector<long long> > p(n, vector<long long>(10));
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < 10; j++) cin >> p[i][j];
  long long ans = LLONG_MIN;
  for (long long i = 0; i < 1 << 10; i++) {
    long long res = 0;
    for (long long j = 0; j < n; j++) {
      long long cnt = 0;
      for (long long k = 0; k < 10; k++) {
        if ((i >> k & 1) && (f[j][k])) cnt++;
      }
      res += p[j][cnt];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}
