#include <bits/stdc++.h>
using namespace std;
const int MAX = (1 << 11) - 1;
int N;
int F[100];
int P[100][11];
long long ans = LLONG_MIN;
int main(void) {
  cin >> N;
  for (int n = 0; n < N; ++n) {
    for (int c = 10; c > 0; --c) {
      int num;
      cin >> num;
      F[n] += num << c - 1;
    }
  }
  for (int n = 0; n < N; ++n) {
    for (int p = 0; p < 11; ++p) {
      cin >> P[n][p];
    }
  }
  for (int a = 1; a <= MAX; ++a) {
    long long score = 0LL;
    for (int n = 0; n < N; ++n) {
      int count = 0;
      int t = a & F[n];
      for (int k = 0; k < 10; ++k) {
        if (t >> k & 1) ++count;
      }
      score += P[n][count];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}
