#include <bits/stdc++.h>
using namespace std;
template <size_t N>
bitset<N> to_bitset(vector<int>& v) {
  bitset<N> r;
  for (int i = 0; i < N; i++) {
    r[i] = v[i];
  }
  return r;
}
int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (auto& e1 : f) {
    for (int& e2 : e1) cin >> e2;
    ;
  }
  vector<vector<int>> p(n, vector<int>(11));
  for (vector<int>& e1 : p) {
    for (int& e2 : e1) {
      cin >> e2;
    }
  }
  long long answer = -9999999;
  for (unsigned int i = 1; i < 1024; i++) {
    bitset<10> my{i};
    long long temp = 0;
    for (int j = 0; j < n; j++) {
      temp += p[j][(to_bitset<10>(f[j]) & my).count()];
    }
    if (temp > answer) {
      answer = temp;
    }
  }
  cout << answer << endl;
  return 0;
}
