#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, max = -1000000007;
  cin >> n;
  int op[n][10], p[n][10];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &op[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  int opj[10], opn[n], cnt;
  for (int i = 1; i < 1024; i++) {
    cnt = 0;
    for (int j = 0; j < 10; j++) {
      opj[j] = i % 2;
      i = i / 2;
    }
    for (int k = 0; k < n; k++) {
      opn[k] = 0;
      for (int l = 0; l < 10; l++) {
        if (opj[l] == 1 && op[k][l] == 1) opn[k]++;
      }
      cnt += p[k][opn[k]];
    }
    if (cnt > max) max = cnt;
  }
  cout << max << endl;
  return 0;
}
