#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> open(N, vector<int>(10));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> open.at(i).at(j);
    }
  }
  vector<vector<int>> benefit(N, vector<int>(11));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> benefit.at(i).at(j);
    }
  }
  int64_t joisino = -100000000;
  for (int bit = 0; bit < (1 << 10); bit++) {
    map<int, bool> mp;
    for (int i = 0; i < 10; i++) {
      if (bit & (1 << i)) {
        mp[i] = true;
      }
    }
    if (mp.size() != 0) {
      int64_t bene_x = 0;
      for (int j = 0; j < N; j++) {
        int cnt = 0;
        for (int k = 0; k < 10; k++) {
          if (open.at(j).at(k) == 1 && mp.count(k)) {
            cnt++;
          }
        }
        bene_x += benefit.at(j).at(cnt);
      }
      joisino = max(joisino, bene_x);
    }
  }
  cout << joisino << endl;
}
