#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int flag = 0;
  int f[100][10] = {};
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (10); ++j) {
      cin >> f[i][j];
    }
  int p[100][11] = {};
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (11); ++j) {
      cin >> p[i][j];
    }
  int sum = 0;
  int m_max = -1000000000;
  for (int i = 1; i < (i << 10); i++) {
    int p_max = 0;
    for (int j = 0; j < (n); ++j) {
      int count = 0;
      for (int k = 0; k < (10); ++k) {
        if (f[j][k] && (i >> k & 1)) count++;
      }
      p_max += p[j][count];
    }
    m_max = max(m_max, p_max);
  }
  cout << m_max << endl;
  return 0;
}
