#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 < 11; ++j) {
      cin >> P[i][j];
    }
  }
  int ans = -1 << 21;
  for (int i = 0; i < 10; ++i) {
    string iter = "1";
    for (int j = 0; j < 9 - i; ++j) {
      iter += "0";
    }
    for (int j = 0; j < i; ++j) {
      iter += "1";
    }
    do {
      int counter[N];
      for (int i = 0; i < N; ++i) {
        counter[i] = 0;
      }
      for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 10; ++j) {
          if (iter[j] - '0' == F[i][j] && F[i][j] == 1) {
            counter[i]++;
          }
        }
      }
      int res = 0;
      for (int i = 0; i < N; ++i) {
        res += P[i][counter[i]];
      }
      ans = max(ans, res);
    } while (next_permutation(iter.begin(), iter.end()));
  }
  cout << ans << endl;
}
