#include <bits/stdc++.h>
using namespace std;
using lint = long long;
lint minf = -1e18;
signed main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10, 0));
  vector<vector<int>> p(n, vector<int>(11, 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];
  lint ans = minf;
  for (int bit = 0; bit < 1 << 10; bit++) {
    lint sm = 0ll;
    for (int i = 0; i < n; i++) {
      int cn = 0;
      for (int j = 0; j < 10; j++) {
        if (bit >> j & 1) cn += f[i][j];
      }
      sm += p[i][cn];
    }
    ans = max(ans, sm);
  }
  cout << ans << endl;
}
