#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, f[100][10], p[100][11], a[10], l, k, max = -2000000000, s;
  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 <= 10; j++) {
      cin >> p[i][j];
    }
  }
  for (k = 1; k <= 1024; k++) {
    j = k;
    for (i = 0; i < 10; i++) {
      if (j % 2 == 1) {
        for (l = 0; l < n; l++)
          if (f[l][i] == 1) a[l]++;
      }
      j >> 1;
    }
    for (i = 0; i < 10; i++) {
      s += p[i][a[i]];
      a[i] = 0;
    }
    if (s > max) max = s;
    s = 0;
  }
  cout << max << endl;
  return 0;
}
