#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> F[i][j];
    }
  }
  vector<vector<int64_t>> P(N, vector<int64_t>(11));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= 10; ++j) {
      cin >> P[i][j];
    }
  }
  int64_t ans = -(1 << 28);
  for (int i = 1; i < (2 << 9); ++i) {
    int64_t sum = 0;
    for (int j = 0; j < N; ++j) {
      int cnt = 0;
      for (int k = 0; k < 10; ++k) {
        if ((i >> k) & F[j][k]) {
          cnt++;
        }
      }
      sum += P[j][cnt];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
