#include <bits/stdc++.h>
using namespace std;
int bitcount(int c) {
  int num = 0;
  for (; c != 0; c &= (c - 1)) num++;
  return num;
}
int main() {
  int n;
  int f[100] = {};
  int p[100][11];
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      int tmp;
      cin >> tmp;
      tmp <<= j;
      f[i] += tmp;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  int maxvalue = -9999999;
  for (int i = 1; i < 1024; i++) {
    int value = 0;
    for (int j = 0; j < n; j++) {
      int c = f[j] & i;
      int d = bitcount(c);
      value += p[j][d];
    }
    if (value > maxvalue) {
      maxvalue = value;
    }
  }
  cout << maxvalue << endl;
  return 0;
}
