#include <bits/stdc++.h>
using namespace std;
const int MAX = 999999999;
int bitcount(int n) {
  int out = 0;
  while (n) {
    out += 1 & n;
    n /= 2;
  }
  return out;
}
int main() {
  int n;
  cin >> n;
  vector<int> open(n);
  for (int i = 0; i < n; i++) {
    int inp = 0;
    for (int j = 0; j < 10; j++) {
      int tmp;
      cin >> tmp;
      inp += tmp * pow(2, 9 - j);
    }
    open[i] = inp;
  }
  vector<vector<int>> score(n, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) cin >> score[i][j];
  }
  int joisino = 0, max_score = -999999999;
  for (; joisino < 1024; joisino++) {
    int tmp_cnt = 0;
    int tmp_score = 0;
    for (int i = 0; i < n; i++) {
      int and_time = bitcount((int)(joisino & open[i]));
      tmp_score += score[i][and_time];
      if (and_time > 0) {
        tmp_cnt++;
      }
    }
    if (tmp_cnt > 0) {
      max_score = max(max_score, tmp_score);
    }
  }
  cout << max_score << endl;
}
