#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<vector<long long>> wow;
  vector<vector<long long>> scores;
  for (long long i = 0; i < n; ++i) {
    vector<long long> now;
    for (long long q = 0; q < 11; ++q) {
      long long tmp;
      cin >> tmp;
      now.push_back(tmp);
    }
    wow.push_back(now);
  }
  for (long long i = 0; i < n; ++i) {
    vector<long long> now;
    for (long long q = 0; q < 10; ++q) {
      long long tmp;
      cin >> tmp;
      now.push_back(tmp);
    }
    scores.push_back(now);
  }
  long long ans = -3000000000000000000;
  for (long long i = 1; i < 1024; ++i) {
    long long pre_ans = 0;
    for (long long q = 0; q < wow.size(); ++q) {
      long long cnt = 0;
      long long copy = i;
      for (long long j = 0; j < 10; ++j) {
        if (wow[q][j] == 1 && copy % 2 == 1) cnt++;
        copy /= 2;
      }
      pre_ans += scores[q][cnt];
    }
    ans = max(ans, pre_ans);
  }
  cout << ans << endl;
  return 0;
}
