#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-14;
const double PI = acos(-1.0);
int main() {
  int n;
  scanf("%d", &n);
  vector<bitset<10> > v;
  for (int i = (int)(0); i < (int)(n); i++) {
    string nums;
    for (int j = (int)(0); j < (int)(10); j++) {
      string a;
      cin >> a;
      nums += a;
    }
    v.push_back(bitset<10>(nums));
  }
  vector<vector<int> > p;
  for (int i = (int)(0); i < (int)(n); i++) {
    int a;
    vector<int> tmp;
    for (int j = (int)(0); j < (int)(11); j++) {
      scanf("%d", &a);
      tmp.push_back(a);
    }
    p.push_back(tmp);
  }
  int ans = -INT_MAX / 3;
  for (int i = (int)(1); i < (int)(2 << 9); i++) {
    int sum = 0;
    for (int j = (int)(0); j < (int)(n); j++) {
      int b = (v[j] & bitset<10>(i)).count();
      sum += p[j][b];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
