#include <bits/stdc++.h>
using namespace std;
const int POW[11] = {0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int main() {
  int N;
  cin >> N;
  int** F = new int*[N];
  int** P = new int*[N];
  for (int i = 0; i < N; i++) {
    F[i] = new int[11];
    P[i] = new int[11];
  }
  for (int i = 0; i < N; i++) {
    F[i][0] = 0;
    for (int j = 1; j < 11; j++) {
      cin >> F[i][j];
      F[i][0] += F[i][j] * POW[j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  int c = 0;
  int res = INT_MIN;
  string s;
  for (int k = 0; k < 1024; k++) {
    int cmax = 0;
    for (int i = 0; i < N; i++) {
      c = ((F[i][0]) & (k));
      s = "";
      for (int a = c; a; a /= 2) {
        s += (a % 2 ? '1' : '0');
      }
      reverse(s.begin(), s.end());
      int cc = 0;
      for (int j = 0; j < s.length(); j++) {
        if (s[j] == '1') cc++;
      }
      cmax += P[i][cc];
    }
    res = (res > cmax ? res : cmax);
  }
  cout << res << endl;
  for (int i = 0; i < N; i++) {
    delete[] F[i];
    delete[] P[i];
  }
  delete[] F;
  delete[] P;
  return 0;
}
