#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<bitset<10>> F(N);
  for (int i = 0; i < N; ++i) {
    string tmp;
    for (int j = 0; j < 10; ++j) {
      string f;
      cin >> f;
      tmp += f;
    }
    F[i] = bitset<10>(tmp);
  }
  vector<vector<int>> P(N, vector<int>(11));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 11; ++j) {
      cin >> P[i][j];
    }
  }
  int ans = -1e8;
  for (int j = 1; j < 1024; ++j) {
    int sum = 0;
    for (int i = 0; i < N; ++i) {
      bitset<10> tmp = bitset<10>(j) & F[i];
      sum += P[i][tmp.count()];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
