#include <bits/stdc++.h>
using namespace std;
void CINT() {}
template <class Head, class... Tail>
void CINT(Head&& head, Tail&&... tail) {
  cin >> head;
  CINT(move(tail)...);
}
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;
int F[575][77];
int P[575][77];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  CINT(N);
  for (int i = (int)0; i < (int)N; ++i) {
    for (int j = (int)0; j < (int)10; ++j) {
      cin >> F[i][j];
    }
  }
  for (int i = (int)0; i < (int)N; ++i) {
    for (int j = (int)0; j < (int)10; ++j) {
      cin >> P[i][j];
    }
  }
  int ans = -INF;
  for (int bit = (int)1; bit < (int)(1 << 10); ++bit) {
    int cnt = 0;
    int tmp = 0;
    for (int h = (int)0; h < (int)N; ++h) {
      int cnt = 0;
      for (int i = (int)0; i < (int)10; ++i) {
        if (((bit >> i) & 1) && (F[h][i] == 1)) {
          cnt++;
          if (bit == 32)
            cerr << "cnt"
                 << ":" << cnt << endl;
          ;
        }
      }
      if (bit == 32)
        cerr << "cnt"
             << ":" << cnt << endl;
      ;
      tmp += P[h + 1][cnt];
      if (bit == 32)
        cerr << "h"
             << ":" << h << endl;
      ;
    }
    if (tmp == 0)
      cerr << "bit"
           << ":" << bit << endl;
    ;
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
