#include <bits/stdc++.h>
int main(void) {
  int N = 0;
  std::cin >> N;
  std::vector<std::vector<int>> F(N);
  for (auto& vec : F) {
    vec.resize(10);
    for (int i = 0; i < 10; i++) std::cin >> vec[i];
  }
  std::vector<std::vector<int>> P(N);
  for (auto& vec : P) {
    vec.resize(11);
    for (int i = 0; i < 11; i++) std::cin >> vec[i];
  }
  const int mask[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int max = -(0xffffffff - 1);
  int sum = 0;
  for (int joisino = 1; joisino < 1024; joisino++) {
    for (int i = 0; i < N; i++) {
      int sum_n = 0;
      for (int j = 0; j < 10; j++) {
        if ((joisino & mask[j]) && F[i][j]) sum_n++;
      }
      sum += P[i][sum_n];
    }
    if (sum > max) {
      max = sum;
    }
    sum = 0;
  }
  std::cout << max << std::endl;
  return 0;
}
