#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18L + 1;
int main() {
  int N;
  cin >> N;
  vector<vector<int> > F(N);
  for (int i = 0; i < (N); ++i) {
    vector<int> temp(10);
    for (int j = 0; j < (10); ++j) {
      cin >> temp[j];
    }
    F[i] = temp;
  }
  vector<vector<int> > P(N);
  for (int i = 0; i < (N); ++i) {
    vector<int> temp(11);
    for (int j = 0; j < (11); ++j) {
      cin >> temp[j];
    }
    P[i] = temp;
  }
  long long ans = -1e9;
  for (int i = 0; i < (10); ++i) {
    long long profit = 0;
    for (int j = 0; j < (N); ++j) {
      if (F[j][i]) profit += P[j][1];
    }
    ans = max(ans, profit);
  }
  for (int i = 1; i < (1 << 10); i++) {
    long long profit = 0;
    int days = __builtin_popcount(i);
    for (int j = 0; j < N; j++) {
      int cnt = 0;
      for (int k = 0; k < 10; k++) {
        if ((i >> k) & 1 && F[j][k]) cnt++;
      }
      profit += P[j][cnt];
    }
    ans = max(ans, profit);
  }
  cout << ans << endl;
  return 0;
}
