#include <bits/stdc++.h>
using namespace std;
int bitCount(int i) {
  int ret = 0;
  while (i != 0) {
    if (i % 2 == 1) {
      ret++;
    }
    i /= 2;
  }
  return ret;
}
int main(int argc, const char* argv[]) {
  long n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10, 0));
  vector<int> fb(n, 0);
  vector<vector<int>> p(n, vector<int>(10, 0));
  int tmp;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> tmp;
      fb[i] += pow(2, 9 - j) * tmp;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  long long m = -99999999999;
  for (int i = 1; i < (1 << 10); i++) {
    long long sum = 0;
    for (int j = 0; j < n; j++) {
      sum += p[j][bitCount(i & fb[j])];
      ;
    }
    m = max(m, sum);
  }
  cout << m << endl;
  return 0;
}
