#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using Int = int;
using Double = double;
using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;
const double PI = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) {
    is >> x;
  }
  return is;
}
template <typename T>
string join(const vector<T>& vec, string sep = " ") {
  stringstream ss;
  for (int i = 0; i < vec.size(); i++) {
    ss << vec[i] << (i + 1 == vec.size() ? "" : sep);
  }
  return ss.str();
}
int solve(int n, const M& fss, const M& pss) {
  vector<bitset<10>> gs(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      gs[i].set(j, fss[i][j] == 1);
    }
  }
  int res = -INF;
  for (ull x = 1; x < (1uLL << 10); x++) {
    int p = 0;
    for (int i = 0; i < n; i++) {
      int c = (gs[i] & bitset<10>(x)).count();
      p += pss[i][c];
    }
    res = max(res, p);
  }
  return res;
}
int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  M fss(n, V(10));
  cin >> fss;
  M pss(n, V(11));
  cin >> pss;
  cout << solve(n, fss, pss) << endl;
  return 0;
}
