#include <bits/stdc++.h>
using namespace std;
int N;
int F[100][10];
int Y[10];
int x = 0;
int P[100][11];
int Max = -10000000;
void chan(int i, int c);
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j <= 10; j++) P[i][j] = 0;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 10; j++) cin >> P[i][j];
  }
  chan(0, 0);
  chan(0, 1);
  cout << Max;
  return 0;
}
void chan(int i, int c) {
  if (i == 10) {
    x = 0;
    int t = 0;
    for (int k = 0; k < 10; k++) {
      if (Y[k] == 1) t++;
    }
    if (t == 0) return;
    for (int p = 0; p < N; p++) {
      int count = 0;
      for (int q = 0; q < 10; q++) {
        if (Y[q] == 1 && F[p][q] == 1) {
          count++;
        }
      }
      x += P[p][count];
    }
    if (Max < x) Max = x;
    return;
  }
  Y[i] = c;
  chan(i + 1, 0);
  chan(i + 1, 1);
}
