#include <bits/stdc++.h>
using namespace std;
int matrix[101][11];
int main() {
  int n;
  scanf("%d", &n);
  ;
  int arr[n], val;
  for (int i = 0; i < n; ++i) {
    int num = 0;
    for (int j = 9; j >= 0; --j) {
      scanf("%d", &val);
      ;
      if (val) num |= (1 << j);
    }
    arr[i] = num;
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 11; ++j) scanf("%d", &matrix[i][j]);
  ;
  long long maxi = -10000010;
  for (int i = 1; i < (1 << 10); ++i) {
    long long sum = 0;
    for (int j = 0; j < n; ++j) {
      int counter = 0;
      int number = i & arr[j];
      for (int k = 0; k < 10; ++k)
        if (number & (1 << k)) counter++;
      sum += matrix[j][counter];
    }
    maxi = max(maxi, sum);
  }
  cout << maxi << endl;
}
