#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
constexpr long long INF = numeric_limits<long long>::max() / 2;
using Graph = vector<vector<long long>>;
signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  long long A[N][10];
  long long pair<long long, long long>[N][10];
  for (long long i = 0; i < (long long)(N); i++) {
    for (long long j = 0; j < (long long)(10); j++) {
      cin >> A[i][j];
    }
  }
  for (long long i = 0; i < (long long)(N); i++) {
    for (long long j = 0; j < (long long)(10); j++) {
      cin >> pair<long long, long long>[i][j];
    }
  }
  long long ans = -INF;
  for (long long bit = 1; bit < (1 << 10); ++bit) {
    long long sum = 0;
    for (long long i = 0; i < (long long)(N); i++) {
      long long count = 0;
      for (long long j = 0; j < (long long)(10); j++) {
        if (bit & (A[i][j] << j)) {
          count++;
        }
      }
      sum += pair<long long, long long>[i][count];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
