#include <bits/stdc++.h>
using namespace std;
int k[11][100 + 1], p[11][100 + 1];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      cin >> k[j][i];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[j][i];
    }
  }
  int q[11] = {0};
  q[10] = 1;
  int ans = -100000000;
  while (q[0] == 0) {
    int j = 10;
    while (q[j] == 1) {
      j--;
    }
    q[j] = 1;
    if (j == 0) break;
    for (int i = j + 1; i <= 10; i++) {
      q[i] = 0;
    }
    int pro = 0;
    int w[n + 1];
    memset(w, 0, sizeof(w));
    for (int i = 1; i <= 10; i++) {
      if (q[i] == 0) continue;
      for (j = 1; j <= n; j++) {
        if (k[i][j] && q[i]) {
          w[j]++;
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      pro += p[w[i]][i];
    }
    if (pro > ans) ans = pro;
  }
  cout << ans;
  return 0;
}
