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