#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<bitset<10> > F;
  vector<vector<int> > P;
  for (int i = 0; i < N; ++i) {
    string line;
    for (int j = 0; j < 10; ++j) {
      string ch;
      cin >> ch;
      line += ch;
    }
    F.push_back(bitset<10>(line));
  }
  for (int i = 0; i < N; ++i) {
    vector<int> v;
    for (int j = 0; j <= 10; ++j) {
      int t;
      cin >> t;
      v.push_back(t);
    }
    P.push_back(v);
  }
  int result = -100000000;
  for (unsigned int subset = 0x001; subset < 0x400; ++subset) {
    bitset<10> bs(subset);
    int profit = 0;
    for (int i = 0; i < N; ++i) {
      profit += P[i][(bs & F[i]).count()];
    }
    if (result < profit) {
      result = profit;
    }
  }
  cout << result << '\n';
  return 0;
}
