#include <bits/stdc++.h>
using namespace std;
string YN(bool y) { return (y ? "YES" : "NO"); }
string yn(bool y) { return (y ? "Yes" : "No"); }
string ON(bool y) { return (y ? "OK" : "NG"); }
int P[100][11];
bool F[100][10], Open[10];
void DFS(int n, int i, bool flag, int *max) {
  if (i >= 10) {
    bool fl = false;
    for (int k = (int)(0); k < (int)(10); k++) {
      fl = Open[k];
    }
    if (!fl) return;
    for (int k = (int)(0); k < (int)(10); k++) {
    }
    int value = 0;
    for (int j = (int)(0); j < (int)(n); j++) {
      int count = 0;
      for (int k = (int)(0); k < (int)(10); k++) {
        if (Open[k] && F[j][k]) count++;
      }
      value += P[j][count];
    }
    if (*max < value) *max = value;
    return;
  }
  Open[i] = flag;
  DFS(n, i + 1, true, max);
  DFS(n, i + 1, false, max);
}
int main(void) {
  int n, max = -1000000000;
  cin >> n;
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(10); j++) {
      cin >> F[i][j];
    }
  }
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(11); j++) {
      cin >> P[i][j];
    }
  }
  DFS(n, 0, true, &max);
  DFS(n, 0, false, &max);
  cout << max << endl;
}
