#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
int n;
char f[100][10];
int p[100][11];
int main() {
  cin >> n;
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)10; j++) {
      cin >> f[i][j];
    }
  }
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)11; j++) cin >> p[i][j];
  int max = -INF;
  for (int bit = 1; bit < (1 << 10); bit++) {
    int sum = 0;
    bitset<10> s(bit);
    for (int i = 0; i < n; i++) {
      int count = 0;
      bitset<10> t(f[i]);
      auto c = bitset<10>(s & t);
      for (int j = 0; j < (int)10; j++)
        if (c.test(j)) count++;
      sum += p[i][count];
    }
    if (sum > max) max = sum;
  }
  cout << max << endl;
}
