#include <bits/stdc++.h>
using ll = long long;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <int id>
struct CompTupleBy {
  template <class T>
  bool operator()(const T& a, const T& b) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> fvec;
  vector<vector<int>> pvec;
  for (int(i) = 0; (i) < (n); (i)++) {
    vector<int> fv;
    for (int(j) = 0; (j) < (10); (j)++) {
      int f;
      cin >> f;
      fv.push_back(f);
    }
    fvec.push_back(fv);
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    vector<int> pv;
    for (int(j) = 0; (j) < (11); (j)++) {
      int p;
      cin >> p;
      pv.push_back(p);
    }
    pvec.push_back(pv);
  }
  int ans = -10000000;
  for (int bit = 1; bit < (1 << 10); bit++) {
    int cc = 0;
    for (int(i) = 0; (i) < (n); (i)++) {
      int c = 0;
      for (int j = 0; j < 10; j++) {
        if (((bit >> j) & 1) && (fvec[i][j] == 1)) {
          c += 1;
        }
      }
      cc += pvec[i][c];
    }
    ans = max(ans, cc);
  }
  cout << ans << endl;
}
