#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int F[N][10], P[N][11];
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < 10; ++j) cin >> F[i][j];
  for (int i = 0; i < N; ++i)
    for (int j = 0; j <= 10; ++j) cin >> P[i][j];
  int ans = -1e9;
  for (int i = 1, s; i < (1 << 10); ++i) {
    s = 0;
    for (int j = 0, t = 0; j < N; ++j) {
      for (int k = 0; k < 10; ++k)
        if (i >> k & F[j][k]) ++t;
      s += P[j][t];
    }
    ans = max(s, ans);
  }
  cout << ans;
  return 0;
}
