#include <bits/stdc++.h>
using namespace std;
int n;
int f[100][10];
int p[100][11];
int binary[10];
void nishinsu(int decimal) {
  int i;
  binary[10] = {};
  for (i = 0; decimal > 0; i++) {
    binary[i] = decimal % 2;
    decimal = decimal / 2;
  }
}
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 < (n); ++i) {
    for (int j = (0); j < (11); ++j) {
      cin >> p[i][j];
    }
  }
  int max = -1000000000;
  for (int i = (1); i < (1023); ++i) {
    nishinsu(i);
    int sum = 0;
    for (int j = (0); j < (n); ++j) {
      int c = 0;
      for (int k = (0); k < (10); ++k) {
        if (binary[k] == 1 && f[j][k] == 1) {
          c++;
        }
      }
      sum += p[j][c];
    }
    if (sum > max) {
      max = sum;
    }
  }
  cout << max << endl;
  return 0;
}
