#include <bits/stdc++.h>
using namespace std;
void binary(int *J, int n);
int main() {
  int N;
  int F[100][10];
  int P[100][11];
  int J[10];
  int C[100] = {};
  int profits = 0, max = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  for (int i = 1; i <= 1024; i++) {
    binary(J, i);
    for (int j = 0; j < N; j++) C[j] = 0;
    profits = 0;
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < 10; k++) {
        C[j] += F[j][k] * J[k];
      }
    }
    for (int j = 0; j < N; j++) {
      profits += P[j][C[j]];
    }
    if (profits > max) max = profits;
  }
  cout << max;
  return 0;
}
void binary(int *J, int n) {
  for (int i = 0; i < 10; i++) {
    J[i] = n % 2;
    n = n / 2;
  }
}
