#include <bits/stdc++.h>
const int MAX = 100000000;
using namespace std;
int in() {
  int temp;
  scanf("%d", &temp);
  return temp;
}
long long lin() {
  long long temp;
  scanf("%lld", &temp);
  return temp;
}
int main() {
  int N = in();
  int F[N][11];
  for (auto i = 0; i < N; i++) {
    for (auto j = 1; j < 11; j++) {
      F[i][j] = in();
    }
  }
  int P[N][11];
  for (auto i = 0; i < N; i++) {
    for (auto j = 0; j < 11; j++) {
      P[i][j] = in();
    }
  }
  int profitMax = -MAX;
  int profit;
  for (auto i = 1; i < (1 << 10); i++) {
    profit = 0;
    int open[11];
    for (auto j = 1; j < 11; j++) {
      open[j] = (i >> (j - 1)) & 1;
    }
    for (auto k = 0; k < N; k++) {
      auto countTemp = 0;
      for (auto l = 1; l < 11; l++) {
        countTemp += (open[l] == 1 && F[k][l] == 1);
      }
      profit += P[k][countTemp];
    }
    if (profitMax < profit) profitMax = profit;
  }
  cout << profitMax << endl;
  return 0;
}
