#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int Pi[N][10];
  for (int i = 0; i < (int)N; i++) {
    for (int j = 0; j < (int)10; j++) {
      cin >> Pi[i][j];
    }
  }
  int Ci[N][11];
  for (int i = 0; i < (int)N; i++) {
    for (int j = 0; j < (int)11; j++) {
      cin >> Ci[i][j];
    }
  }
  int maxValue = -10000000;
  for (int i = 1; i < 1024; i++) {
    int value = 0;
    for (int k = 0; k < (int)N; k++) {
      int openCount = 0;
      for (int h = 0; h < (int)10; h++) {
        if ((i & (1 << h)) > 0 && Pi[k][h] > 0) {
          openCount++;
        }
      }
      value += Ci[k][openCount];
    }
    maxValue = max(maxValue, value);
  }
  cout << maxValue << endl;
  return 0;
}
