#include <bits/stdc++.h>
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int, int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
int main() {
  int n;
  cin >> n;
  vvint f(n, vint(10)), p(n, vint(10));
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(10); j++) cin >> f[i][j];
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(11); j++) cin >> p[i][j];
  int ans = -inf;
  for (int i = 1; i < (int)(1 << 10); i++) {
    int sum = 0;
    for (int j = 0; j < (int)(n); j++) {
      int ct = 0;
      for (int k = 0; k < (int)(10); k++) {
        if ((i >> k & 1) && f[j][k]) ct++;
      }
      sum += p[j][ct];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
