#include <bits/stdc++.h>
int main() {
  const int n = 10;
  int N;
  std::cin >> N;
  int F[N][n], P[N][n + 1];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < n; ++j) {
      std::cin >> F[i][j];
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < n + 1; ++j) {
      std::cin >> P[i][j];
    }
  }
  int ans = -100000000;
  for (int i = 1; i < 1024; ++i) {
    std::vector<int> c(N, 0);
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        for (int k = 0; k < N; ++k) {
          c[k] += F[k][j];
        }
      }
    }
    int p = 0;
    for (int j = 0; j < N; ++j) {
      p += P[j][c[j]];
    }
    ans = std::max(p, ans);
  }
  std::cout << ans << std::endl;
  return 0;
}
