#include <bits/stdc++.h>
using namespace std;
int N;
int solve() {
  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 ret = -100000000;
  for (int bit = 1; bit < (1 << 10); bit++) {
    vector<int> S;
    for (int i = 0; i < 10; i++) {
      if (bit & (1 << i)) {
        S.push_back(i);
      }
    }
    int sumP = 0;
    for (int i = 0; i < N; i++) {
      int countF = 0;
      for (int j : S) {
        if (F[i][j] == 1) countF++;
      }
      sumP += P[i][countF];
    }
    ret = max(sumP, ret);
  }
  return ret;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  cout << solve() << endl;
}
