#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;
template <class T>
void vin(vector<T>& v, int n) {
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
}
int b[101];
int p[101][12];
int main() {
  int N;
  cin >> N;
  for (int(i) = (0); (i) < (int)(N); ++(i)) {
    for (int(j) = (0); (j) < (int)(10); ++(j)) {
      int tmp;
      cin >> tmp;
      b[i] = (b[i] << 1) + tmp;
    }
  }
  for (int(i) = (0); (i) < (int)(N); ++(i)) {
    for (int(j) = (0); (j) < (int)(11); ++(j)) {
      cin >> p[i][j];
    }
  }
  int ans = -1e8;
  for (int bit = 1; bit < (1 << 10); ++bit) {
    int tmp = 0;
    for (int(i) = (0); (i) < (int)(N); ++(i)) {
      int c = __builtin_popcount(bit & b[i]);
      tmp += p[i][c];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
