#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<vector<int> > vec(n, vector<int>(10));
  vector<vector<int> > p(n, vector<int>(11));
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(10); j++) cin >> vec.at(i).at(j);
  }
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(11); j++) cin >> p.at(i).at(j);
  }
  int res = -1e8;
  for (int bit = 1; bit < (1 << 10); bit++) {
    int total = 0;
    for (int shop = 0; shop < n; shop++) {
      int cnt = 0;
      vector<int> s;
      for (int i = 0; i < int(10); i++) {
        if (bit & (1 << i)) s.push_back(i);
      }
      for (int k = 0; k < (int)s.size(); k++) {
        if (vec.at(shop).at(s.at(k)) == 1) cnt++;
      }
      int sales = p.at(shop).at(cnt);
      total += sales;
    }
    res = max(res, total);
  }
  cout << res << endl;
}
