#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<bitset<10>> shop(n);
  for (int i = 0; i < (int)(n); i++) {
    bitset<10> tmp;
    for (int j = 0; j < (int)(10); j++) {
      bool f;
      cin >> f;
      tmp.set(j, f);
    }
    shop.at(i) = tmp;
  }
  vector<vector<int>> p(n, vi(11));
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(11); j++) cin >> p.at(i).at(j);
  }
  int ans = 0;
  for (int i = 1; i < (1 << 10); i++) {
    bitset<10> joi(i);
    int ben = 0;
    for (int j = 0; j < (int)(n); j++) {
      bitset<10> mult = (joi & shop.at(j));
      int sum = 0;
      for (int k = 0; k < (int)(10); k++) {
        if (mult.test(k)) sum++;
      }
      ben += p.at(j).at(sum);
    }
    ans = max(ans, ben);
  }
  cout << ans << endl;
}
