#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int main(void) {
  int N;
  cin >> N;
  int F[N][10], pair<int, int>[N][11];
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(10); j++) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(11); j++) {
      cin >> pair<int, int>[i][j];
    }
  }
  int res = -100000000;
  int c[N];
  int profit = 0;
  for (int i = 1; i < (1 << 10); i++) {
    profit = 0;
    for (int j = 0; j < (int)(N); j++) {
      c[j] = 0;
      for (int k = 0; k < (int)(10); k++) {
        c[j] += F[j][k] & (i >> k);
      }
      profit += pair<int, int>[j][c[j]];
    }
    res = max(res, profit);
  }
  cout << res << endl;
  return 0;
}
