#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  int F[N];
  for (int i = 0; i < N; i++) {
    F[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      int f;
      cin >> f;
      F[i] += f * pow(2, 9 - j);
    }
  }
  int P[N][11];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  int ans, MAX_ans = -1000000;
  for (int bit = 1; bit < (1 << 10); bit++) {
    ans = 0;
    for (int i = 0; i < N; i++) {
      bitset<10> x = bit & F[i];
      ans += P[i][x.count()];
    }
    MAX_ans = max(ans, MAX_ans);
  }
  cout << MAX_ans << endl;
}
