#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<vector<bool>> f(n, vector<bool>(11));
  vector<vector<int>> p(n, vector<int>(10));
  for (int i = 0, i_len = (n); i < i_len; ++i) {
    for (int j = 0, j_len = (10); j < j_len; ++j) {
      int a;
      cin >> a;
      f[i][j] = a;
    }
  }
  for (int i = 0, i_len = (n); i < i_len; ++i) {
    for (int j = 0, j_len = (11); j < j_len; ++j) {
      int a;
      cin >> a;
      p[i][j] = a;
    }
  }
  int ma = -1 << 30;
  for (int open = 1, open_len = (1024); open < open_len; ++open) {
    int score = 0;
    for (int i = 0, i_len = (n); i < i_len; ++i) {
      int cnt = 0;
      for (int j = 0, j_len = (10); j < j_len; ++j) {
        if ((open & (1ll << (j))) && f[i][j]) {
          ++cnt;
        }
      }
      score += p[i][cnt];
    }
    chmax(ma, score);
  }
  cout << ma << endl;
  return 0;
}
