#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const ll LLMAX = numeric_limits<long long>::max();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<char>> f(n, vector<char>(10, 0));
  vector<vector<int>> p(n, vector<int>(11, 0));
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (10); j++) cin >> f[i][j];
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (11); j++) cin >> p[i][j];
  vector<int> b(10);
  b[0] = 1;
  for (int i = (1); i < (10); i++) {
    b[i] = b[i - 1] << 1;
  }
  int ans = -INTMAX;
  for (int i = (1); i < ((1 << 10) - 1); i++) {
    int v = 0;
    for (int j = 0; j < (n); j++) {
      int cnt = 0;
      for (int c = 0; c < (10); c++) {
        if ((b[c] & i) && f[j][c] == '1') {
          cnt++;
        }
      }
      v += p[j][cnt];
    }
    ans = max(ans, v);
  }
  cout << ans << endl;
  return 0;
}
