#include <bits/stdc++.h>
using namespace std;
long long INF = 1e9 + 7;
;
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, 1, 0, -1};
signed main() {
  long long N;
  cin >> N;
  vector<vector<long long>> vec(N, vector<long long>(10));
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < 10; j++) {
      cin >> vec[i][j];
    }
  }
  vector<vector<long long>> pair<long long, long long>(N,
                                                       vector<long long>(11));
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < 11; j++) {
      cin >> pair<long long, long long>[i][j];
    }
  }
  long long ans = -INF;
  for (long long bit = 0; bit < (1 << 10); bit++) {
    long long cnt = 0;
    for (long long i = 0; i < N; i++) {
      long long sum = 0;
      for (long long j = 0; j < 10; j++) {
        if (((bit >> j) & 1) && vec[i][j]) {
          sum++;
        }
      }
      cnt += pair<long long, long long>[i][sum];
    }
    if (cnt > ans) {
      ans = cnt;
    }
  }
  cout << ans << endl;
}
