#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long ans = -pow(10, 8);
  cin >> N;
  vector<int> F(N, 0);
  vector<vector<int>> table(N, vector<int>(10 + 1));
  for (int i = 0; i < N; i++) {
    int b;
    for (int k = 9; k >= 0; k--) {
      cin >> b;
      F[i] += b * pow(2, k);
    }
  }
  for (int i = 0; i < N; i++) {
    for (int k = 0; k < 10 + 1; k++) {
      cin >> table[i][k];
    }
  }
  int bin = 1;
  while (bin <= 0b1111111111) {
    long long sum = 0;
    for (int i = 0; i < N; i++) {
      int count = 0;
      for (int k = 0; k < 10; k++) {
        if ((F[i] & bin & (1 << k)) != 0) {
          count++;
        }
      }
      sum += table[i][count];
    }
    if (ans < sum) {
      ans = sum;
    }
    bin++;
  }
  cout << ans << endl;
  return 0;
}
