#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
const int FLAG_NUM = 10;
vector<int> num_to_flags(int x) {
  stringstream ss;
  ss << static_cast<bitset<FLAG_NUM> >(x);
  string s = ss.str();
  vector<int> V(FLAG_NUM);
  for (int i = (0); i < (FLAG_NUM); ++i) {
    V[i] = ctoi(s[i]);
  }
  return V;
}
void pV(vector<int> v) {
  for (auto a : v) {
    cout << a << " ";
  }
  cout << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<vector<int> > F(N);
  for (int i = (0); i < (N); ++i) {
    for (int j = (0); j < (10); ++j) {
      int f;
      cin >> f;
      F[i].push_back(f);
    }
  }
  vector<vector<int> > P(N);
  for (int i = (0); i < (N); ++i) {
    for (int j = (0); j < (11); ++j) {
      int p;
      cin >> p;
      P[i].push_back(p);
    }
  }
  long long max_profit = -inf;
  for (int i = (1); i < (1024); ++i) {
    auto flags = num_to_flags(i);
    long long profit_sum = 0;
    for (int j = (0); j < (N); ++j) {
      auto tenpo = F[j];
      int both_work = 0;
      for (int k = (0); k < (10); ++k) {
        if (tenpo[k] == 1 && flags[k] == 1) {
          both_work++;
        }
      }
      int profit = P[j][both_work];
      profit_sum += profit;
    }
    max_profit = max(max_profit, profit_sum);
  }
  cout << (max_profit) << endl;
  return 0;
}
