#include <bits/stdc++.h>
using namespace std;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> >
    IntReversePrioQueue;
void solve(void) {
  int n;
  cin >> n;
  int isopen[n][10];
  long long benefit[n][11];
  for (int i = 0; i <= n - 1; i++)
    for (int k = 0; k <= 10 - 1; k++) scanf("%d", &isopen[i][k]);
  for (int i = 0; i <= n - 1; i++)
    for (int k = 0; k <= 11 - 1; k++) scanf("%lld", &benefit[i][k]);
  int digit = 0;
  bool flag[11];
  fill(flag, flag + 11, false);
  long long score = -(long)1e+7;
  for (int i = 0; i <= pow(2, 10) - 1 - 1; i++) {
    while (flag[digit]) {
      flag[digit] = false;
      digit++;
    }
    flag[digit] = true;
    digit = 0;
    long long temp_score = 0;
    for (int j = 0; j <= n - 1; j++) {
      int count = 0;
      for (int k = 0; k <= 10 - 1; k++)
        if (isopen[j][k] and flag[k]) count++;
      temp_score += benefit[j][count];
    }
    score = max(score, temp_score);
  }
  cout << score << endl;
}
int main(void) {
  solve();
  return 0;
}
