#include <bits/stdc++.h>
using namespace std;
int sum(long long n) {
  int ans = n % 10;
  while (n / 10) {
    n /= 10;
    ans += n % 10;
  }
  return ans;
}
int main(void) {
  int n;
  int open[101][10];
  int profit[101][11];
  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];
    }
  }
  long long maxi = -100000000;
  long long sum;
  for (int i = 1; i < (1 << 10); i++) {
    sum = 0;
    for (int j = 0; j < n; j++) {
      int count = 0;
      for (int k = 0; k < 10; k++) {
        if (!(i & (1 << k))) continue;
        if (!open[j][k]) continue;
        count++;
      }
      sum += profit[j][count];
    }
    maxi = max(sum, maxi);
  }
  cout << maxi << endl;
  return 0;
}
