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