#include <bits/stdc++.h>
using namespace std;
const long int MAX_N = 100, MAX_P = 10000000;
int main(int argc, char const *argv[]) {
  long long int n, f[MAX_N][5][2], p[MAX_N][11];
  cin >> n;
  vector<bitset<10>> fvec;
  for (size_t i = 0; i < n; i++) {
    bitset<10> bs(0);
    for (size_t j = 0; j < 10; j++) {
      int temp;
      cin >> temp;
      if (temp) bs.set(j);
    }
    fvec.push_back(bs);
  }
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j <= 10; j++) cin >> p[i][j];
  }
  long long int ans = MAX_P * (-1);
  for (size_t i = 1; i < pow(2, 10); i++) {
    bitset<10> joisino(i);
    int point;
    long long int sum = 0;
    for (size_t j = 0; j < n; j++) {
      bitset<10> andbits = joisino & fvec[j];
      point = andbits.count();
      sum += p[j][point];
    }
    if (sum > ans) ans = sum;
  }
  cout << ans << endl;
  return 0;
}
