#include <bits/stdc++.h>
using namespace std;
int open[100];
int profit[100][11];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    int cnt = 0, buf;
    for (int j = 0; j < (10); ++j) {
      cnt <<= 1;
      scanf("%d", &buf);
      cnt += buf;
    }
    open[i] = cnt;
  }
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (11); ++j) {
      scanf("%d", &profit[i][j]);
    }
  long long min = -1e9;
  for (int i = (1); i < (1023); ++i) {
    long long v = 0;
    for (int j = 0; j < (n); ++j)
      v += profit[j][__builtin_popcount(i & open[j])];
    if (v > min) min = v;
  }
  printf("%lld", min);
  return 0;
}
