#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int F[N][10];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> F[i][j];
    }
  }
  int P[N][11];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= 10; ++j) {
      cin >> P[i][j];
    }
  }
  int ans = -1 << 21;
  for (int i = 0b1; i <= 0b1111111111; ++i) {
    int counter[N];
    fill(counter, counter + N, 0);
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < 10; ++k) {
        if ((1 << k & i) && F[j][k]) {
          counter[j]++;
        }
      }
    }
    int res = 0;
    for (int j = 0; j < N; ++j) {
      res += P[j][counter[j]];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
}
