#include <bits/stdc++.h>
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
int main() {
  int N;
  cin >> N;
  vecveci F(N, veci(10));
  vecveci P(N, veci(10));
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (10); ++j) cin >> F[i][j];
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (11); ++j) cin >> P[i][j];
  int ans = 1000000000;
  ans *= -1;
  for (int bit = 0; bit < (1 << 10); bit++) {
    if (bit == 0) continue;
    int total = 0;
    for (int i = 0; i < (N); ++i) {
      int cnt = 0;
      for (int j = 0; j < (10); ++j)
        if ((bit & (1 << j)) && F[i][j]) cnt++;
      total += P[i][cnt];
    }
    chmax(ans, total);
  }
  cout << ans << endl;
}
