#include <bits/stdc++.h>
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  for (auto &Fi : F)
    for (auto &Fijk : Fi) cin >> Fijk;
  vector<vector<int>> P(N, vector<int>(11));
  for (auto &Pi : P)
    for (auto &Pic : Pi) cin >> Pic;
  int maxPayoff = INT_MIN;
  for (int bit = 1; bit < (1 << 10); ++bit) {
    vector<int> overlapNums(N, 0);
    for (int t = 0; t < 10; ++t) {
      if (bit & (1 << t)) {
        for (int i = 0; i < N; ++i) {
          if (F[i][t] == 1) ++overlapNums[i];
        }
      }
    }
    int tmpPayoff = 0;
    for (int i = 0; i < N; ++i) {
      tmpPayoff += P[i][overlapNums[i]];
    }
    maxPayoff = max(maxPayoff, tmpPayoff);
  }
  cout << maxPayoff << endl;
}
