#include <bits/stdc++.h>
using namespace std;
int main() {
  ios ::sync_with_stdio(false);
  int n, f[101][11], p[101][12], s[11];
  int i, j, k, m = -10000001, sum, sumj;
  memset(f, 0, sizeof(f));
  memset(p, 0, sizeof(p));
  cin >> n;
  for (i = 0; i < n; ++i) {
    for (j = 0; j < 10; ++j) {
      cin >> f[i][j];
    }
  }
  for (i = 0; i < n; ++i) {
    for (j = 0; j < 11; ++j) {
      cin >> p[i][j];
    }
  }
  for (i = 1; i < 1024; ++i) {
    sum = 0;
    memset(s, 0, sizeof(s));
    for (j = 0; j < 10; ++j) {
      s[9 - j] = (i >> j) & 1;
    }
    for (j = 0; j < n; ++j) {
      sumj = 0;
      for (k = 0; k < 10; ++k) {
        if (s[k] & f[j][k]) {
          ++sumj;
        }
      }
      sum += p[j][sumj];
    }
    if (m < sum) {
      m = sum;
    }
  }
  cout << m;
  return 0;
}
