#include <bits/stdc++.h>
using namespace std;
long long ci(bitset<32> sis, bitset<32> fi) {
  auto t = fi & sis;
  return t.count();
}
long long prof(bitset<32> sis, vector<bitset<32>> f,
               vector<vector<long long>> p) {
  long long n = f.size();
  vector<long long> c(n);
  long long csum = 0;
  for (int i = 0; i < (int)(n); i++) {
    c[i] = ci(sis, f[i]);
    csum += c[i];
  }
  long long sum = 0;
  for (int i = 0; i < (int)(n); i++) {
    sum += p[i][c[i]];
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  string kk = "";
  vector<bitset<32>> f(n, 0);
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(10); j++) {
      char k;
      cin >> k;
      kk.push_back(k);
    }
    f[i] = bitset<32>(kk);
  }
  vector<vector<long long>> p(n, vector<long long>(11));
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(11); j++) cin >> p[i][j];
  long long ma = INT_MIN;
  for (int i = 1; i < (1 << 10); i++) {
    ma = max(ma, prof(i, f, p));
  }
  cout << ma << endl;
  return 0;
}
