#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
struct io {
  io() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
};
const int INF = INT_MAX;
const long long int LLINF = 1LL << 60;
const long long int MOD = 1000000007;
const double EPS = 1e-9;
int main(void) {
  int n;
  cin >> n;
  vector<vector<int> > v(n, vector<int>(10));
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (10); ++j) cin >> v[i][j];
  vector<vector<int> > p(n, vector<int>(11));
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (11); ++j) cin >> p[i][j];
  int ans = -INF;
  for (int i = 1; i < (1 << 10); i++) {
    string s = "";
    int t = i;
    while (t > 0) {
      s += t % 2 + '0';
      t /= 2;
    }
    int tmp = 0;
    reverse(s.begin(), s.end());
    for (int j = 0; j < n; j++) {
      int itti = 0;
      for (int k = 0; k < (10); ++k) {
        if (v[j][k] == 1 && s[k] == '1') {
          itti++;
        }
      }
      tmp += p[j][itti];
    }
    chmax(ans, tmp);
  }
  cout << (ans) << '\n';
}
