#include <bits/stdc++.h>
void set(std::array<int, 10> &J, int num);
void print(std::array<int, 10> J);
void set(std::array<int, 10> &J, int num) {
  int i = J.size() - 1;
  while (num > 0) {
    J.at(i--) = num % 2;
    num /= 2;
  }
}
void print(std::array<int, 10> J) {
  int size = J.size();
  for (int i = 0; i < size; i++) std::cout << J[i] << ' ';
  std::cout << std::endl;
}
int main() {
  int N;
  std::cin >> N;
  std::array<int, 10> F[N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) std::cin >> F[i][j];
  }
  std::array<int, 11> P[N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) std::cin >> P[i][j];
  }
  std::array<int, 10> J = {};
  int ans = -10000000;
  for (int i = 1; i < 1024; i++) {
    int profit = 0;
    set(J, i);
    for (int j = 0; j < N; j++) {
      int same = 0;
      for (int k = 0; k < 10; k++)
        if (J[k] == 1 && F[j].at(k) == 1) same++;
      profit += P[j].at(same);
    }
    if (profit > ans) {
      ans = profit;
    }
  }
  std::cout << ans;
  return 0;
}
