#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1000000000;
constexpr int MODULO = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> f, p;
  for (int i = 0; i < n; i++) {
    f.push_back({});
    for (int j = 0; j < 10; j++) {
      int a;
      cin >> a;
      f[i].push_back(a);
    }
  }
  for (int i = 0; i < n; i++) {
    p.push_back({});
    for (int j = 0; j < 11; j++) {
      int a;
      cin >> a;
      p[i].push_back(a);
    }
  }
  int64_t maxim = 0;
  for (int i = 1; i <= 1023; i++) {
    int64_t sum = 0;
    for (int j = 0; j < p.size(); j++) {
      int opent = 0;
      for (int k = 0; k < f[j].size(); k++) {
        if ((i & (1 << k)) >= 1) opent += f[j][k];
      }
      sum += p[j][opent];
    }
    maxim = max(maxim, sum);
  }
  cout << maxim << '\n';
}
