#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
int main() {
  int n;
  cin >> n;
  vector<lint> f(n);
  vector<vector<int>> p(n, vector<int>(10));
  for (int i = (0), i_end_ = (n); i < i_end_; i++) {
    for (int j = (0), j_end_ = (10); j < j_end_; j++) {
      int tmp;
      cin >> tmp;
      f[i] += tmp * pow(2, 9 - j);
    }
  }
  for (int i = (0), i_end_ = (n); i < i_end_; i++) {
    for (int j = (0), j_end_ = (11); j < j_end_; j++) {
      cin >> p[i][j];
    }
  }
  lint INF = 10000000000000;
  lint max_benefit = -INF;
  for (int bit = 1; bit < (1 << 10); ++bit) {
    lint benefit = 0;
    for (int i = (0), i_end_ = (n); i < i_end_; i++) {
      int tmp = (bit & f[i]);
      int c = 0;
      for (int j = (10) - 1, j_begin_ = (0); j >= j_begin_; j--) {
        c += tmp / (1 << j);
        tmp %= (1 << j);
      }
      benefit += p[i][c];
    }
    max_benefit = max(max_benefit, benefit);
  }
  for (int i = (0), i_end_ = (n); i < i_end_; i++) {
    std::stringstream ss;
    ss << std::bitset<10>(f[i]);
    std::string s = ss.str();
  }
  cout << max_benefit << "\n";
  return 0;
}
