#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
int N;
bool F[103][10];
int P[103][10];
int main() {
  cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
  ;
  cin >> N;
  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 = -INF;
  for (int bit = 0; bit < 1 << 10; ++bit) {
    int tmp = 0;
    if (bit == 0) continue;
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < 10; ++k) {
        if (!F[j][k]) continue;
        if (1 << k & bit) tmp += P[j][k];
      }
    }
    ans = max(tmp, ans);
  }
  cout << ans << "\n";
  return 0;
}
