#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
bool open[10];
long long answer = -100000000, N;
long long F[MAXN][10];
long long P[MAXN][11];
void BruteForce(int x, bool open_close) {
  open[x] = open_close;
  if (x == 9) {
    long long benefit = 0;
    int total_open = 0;
    for (int store = 0; store < N; ++store) {
      int num_open = 0;
      for (int time = 0; time < 10; ++time) {
        if (open[time]) {
          num_open += F[store][time];
          ++total_open;
        }
      }
      benefit += P[store][num_open];
    }
    if (answer < benefit && total_open > 0) answer = benefit;
  } else {
    BruteForce(x + 1, true);
    BruteForce(x + 1, false);
  }
}
int main() {
  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];
    }
  }
  answer = -100000000;
  for (int i = 0; i < 10; ++i) open[i] = true;
  BruteForce(0, true);
  BruteForce(0, false);
  cout << answer << endl;
}
