#include <bits/stdc++.h>
using namespace std;
void Main() {
  int N;
  cin >> N;
  vector<int> F(N);
  for (int i = 0; i < N; i++) {
    int tmp = 0;
    for (int j = 0; j < 10; j++) {
      int flag;
      cin >> flag;
      tmp |= flag << j;
    }
    F[i] = tmp;
  }
  vector<vector<int>> P(N, vector<int>(11));
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 11; j++) cin >> P[i][j];
  long long max = -(1 << 30);
  for (int open = 1; open < 1 << 10; open++) {
    long long sum = 0;
    for (int shop = 0; shop < N; shop++) {
      int hoge = open & F[shop];
      int cnt = 0;
      while (hoge > 0) {
        cnt += hoge % 2;
        hoge /= 2;
      }
      sum += P[shop][cnt];
    }
    if (sum > max) max = sum;
    if (sum == 0) cout << open << endl;
  }
  cout << max << endl;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  Main();
}
