#include <bits/stdc++.h>
using namespace std;
template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
long long int INF = 1000000000000000000;
long long int MOD = 1e9 + 7;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  vector<vector<int>> P(N, vector<int>(10));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  long long int ans = -100000000;
  for (int i = 1; i < (1 << 10); i++) {
    bitset<10> S(i);
    long long int memo = 0;
    vector<int> L(N, 0);
    for (int j = 0; j < 10; j++) {
      if (S.test(j)) {
        for (int k = 0; k < N; k++) {
          if (F[k][j]) {
            L[k]++;
          }
        }
      }
    }
    for (int j = 0; j < N; j++) {
      memo += P[j][L[j]];
    }
    ans = max(ans, memo);
  }
  cout << ans << endl;
}
