#include <bits/stdc++.h>
using namespace std;
int calcScore(const vector<vector<int> >& F, const vector<vector<int> >& P,
              const vector<int>& v) {
  int score = 0;
  for (int i = 0; i < F.size(); i++) {
    int count = 0;
    for (int j = 0; j < v.size(); j++) {
      if (F[i][j] > 0 && v[j] > 0) count++;
    }
    score += P[i][count];
  }
  return score;
}
void print(const vector<int>& v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
int main() {
  int N;
  cin >> N;
  vector<vector<int> > F(N, vector<int>(10));
  vector<vector<int> > P(N, vector<int>(11));
  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 maxScore = INT_MIN;
  vector<int> v(10);
  for (int i = 1; i < 1023; i++) {
    for (int j = 0; j < 10; j++) {
      v[j] = (i >> j) & 0x1;
    }
    int score = calcScore(F, P, v);
    if (score > maxScore) {
      maxScore = score;
    }
  }
  cout << maxScore << endl;
  return 0;
}
