#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int N;
int F[100];
int P[100][11];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  int w;
  for (int i = 0; i < (N); i++) {
    F[i] = 0;
    for (int j = 0; j < (10); j++) {
      cin >> w;
      if (w == 1) F[i] |= (1 << j);
    }
  }
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (11); j++) {
      cin >> w;
      P[i][j] = w;
    }
  }
  int ans = 999999999 * -1;
  int k;
  for (int i = (1 << 10) - 1; i > 0; i--) {
    w = 0;
    for (int j = 0; j < (N); j++) {
      k = __builtin_popcount(i & F[j]);
      w += P[j][k];
    }
    ans = max(ans, w);
  }
  cout << ans << endl;
  return 0;
}
