#include <bits/stdc++.h>
using namespace std;
int n, a[100] = {0}, m = 5;
vector<vector<int>> f, p;
vector<int> q;
void dfs(int i, int a[]) {
  if (i == 10) {
    int d = 0, e = 0;
    for (int(j) = 0; (j) < (n); (j)++) {
      if (a[j]) {
        d += p[j][a[j]];
        e++;
      }
    }
    if (m <= 0 && d <= 0) return;
    if (!e) return;
    m = min(m, d);
    q.push_back(d);
    return;
  }
  int b[100];
  for (int(j) = 0; (j) < (n); (j)++) {
    if (f[j][i])
      b[j] = a[j] + 1;
    else
      b[j] = a[j];
  }
  dfs(i + 1, a);
  dfs(i + 1, b);
}
int main() {
  cin >> n;
  for (int(i) = 0; (i) < (n); (i)++) {
    vector<int> b;
    f.push_back(b);
    for (int(j) = 0; (j) < (10); (j)++) {
      int c;
      cin >> c;
      f[i].push_back(c);
    }
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    vector<int> b;
    p.push_back(b);
    for (int(j) = 0; (j) < (11); (j)++) {
      int c;
      cin >> c;
      p[i].push_back(c);
    }
  }
  dfs(0, a);
  sort((q).begin(), (q).end());
  cout << q[q.size() - 1] << endl;
  return 0;
}
