#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  int open[105][15];
  int profit[105][15];
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> open[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> profit[i][j];
    }
  }
  int count, sum, maxi = -100000000;
  for (int i = 1; i < (1 << 10); i++) {
    sum = 0;
    for (int j = 0; j < n; j++) {
      count = 0;
      for (int k = 0; k < 10; k++) {
        if ((i & (1 << k)) && open[j][k]) count++;
      }
      sum += profit[j][count];
    }
    maxi = max(maxi, sum);
  }
  cout << maxi << endl;
  return 0;
}
