#include <bits/stdc++.h>
using namespace std;
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 ret = -10000000;
  for (int i = 1; i <= (1 << 10) - 1; ++i) {
    vector<int> open(N, 0);
    for (int j = 0; j <= 10; ++j) {
      if (i & 1 << j) {
        for (int k = 0; k < N; k++) {
          if (F[k][j] == 1) open[k]++;
        }
      }
    }
    int temp = 0;
    for (int j = 0; j < N; ++j) {
      temp += P[j][open[j]];
    }
    ret = max(temp, ret);
  }
  cout << ret << endl;
  return 0;
}
