#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, f[105][15], p[105][15], i, a, x, j, mx = -10000000000000000,
                                                       tmp;
  bool is[15];
  cin >> n;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= 10; j++) cin >> f[i][j];
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  a = 0;
  while (a <= 2048) {
    x = a;
    for (i = 0; i < 15; i++) is[i] = 0;
    i = 1;
    while (x != 0) {
      if (x & 1) is[i] = 1;
      x /= 2;
      i++;
    }
    for (i = 1; i <= 5; i++) {
      if (is[i] == 0 && is[i + 5] == 0) break;
    }
    if (i == 6) {
      tmp = 0;
      for (i = 1; i <= n; i++) {
        long long int cnt = 0;
        for (j = 1; j <= 10; j++) {
          if (is[j] == 1 && f[i][j] == 1) cnt++;
        }
        tmp += p[i][cnt];
      }
      mx = max(mx, tmp);
    }
    a++;
  }
  cout << mx;
  return 0;
}
