#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int N, M = 10;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10, 0));
  for (int i = 0; i < (int)(N); i++)
    for (int j = 0; j < (int)(10); j++) cin >> F[i][j];
  vector<vector<int>> P(N, vector<int>(10, 0));
  for (int i = 0; i < (int)(N); i++)
    for (int j = 0; j < (int)(11); j++) cin >> P[i][j];
  long long ans = -1e+16;
  for (int bit = 1; bit < (1 << M); ++bit) {
    vector<int> S;
    for (int i = 0; i < M; ++i)
      if (bit & (1 << i)) S.push_back(i);
    long long ans_sub = 0;
    for (int i = 0; i < N; ++i) {
      int num = 0;
      for (int j = 0; j < S.size(); ++j) {
        num = num + F[i][S[j]];
      }
      ans_sub = ans_sub + P[i][num];
    }
    if (ans_sub > ans) ans = ans_sub;
  }
  cout << ans << endl;
  return 0;
}
