#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
vector<vector<ll> > F, P;
ll MAX = -100100100;
int N;
vector<int> check;
void func(ll bit) {
  for (int i = 0; i < check.size(); i++) {
    check[i] = 0;
  }
  for (int i = 0; i < 10; i++) {
    if ((bit & (1 << i))) {
      for (int j = 0; j < N; j++) {
        if (F[j][i] == 1) {
          check[j]++;
        }
      }
    }
  }
  ll res = 0;
  for (int i = 0; i < N; i++) {
    res += P[i][check[i]];
  }
  MAX = max(MAX, res);
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  F.resize(N, vector<ll>(10));
  P.resize(N, vector<ll>(11));
  check.resize(N, 0);
  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];
    }
  }
  for (ll i = 1; i <= 0b1111111111; i++) {
    func(i);
  }
  cout << MAX;
  return 0;
}
