#include <bits/stdc++.h>
using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int32 n;
  cin >> n;
  int32 f[100][10];
  for (int32 i = (0); i < (n); ++i) {
    for (int32 j = (0); j < (10); ++j) {
      cin >> f[i][j];
    }
  }
  int32 p[100][11];
  for (int32 i = (0); i < (n); ++i) {
    for (int32 j = (0); j < (11); ++j) {
      cin >> p[i][j];
    }
  }
  uint32 i;
  int64 ans = -1e18;
  int64 cur;
  for (i = 1; i < 1024; ++i) {
    cur = 0;
    int32 temp = 0;
    for (int32 j = (0); j < (n); ++j) {
      for (int32 k = (0); k < (10); ++k) {
        if ((((i) >> (k)) & 1) && f[j][k]) {
          ++temp;
        }
      }
      cur += p[j][temp];
    }
    ans = max(ans, cur);
  }
  cout << ans << endl;
  return 0;
}
