#include <bits/stdc++.h>
using namespace std;
int F[100][11], P[100][11];
int main() {
  int n;
  cin >> n;
  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 < (11); ++j) cin >> P[i][j];
  int res = INT_MIN;
  for (int i = (0); i < (1 << 10); ++i) {
    set<int> open;
    vector<int> period(n);
    for (int j = (0); j < (10); ++j)
      if ((i >> j) & 1) {
        for (int k = (0); k < (n); ++k)
          if (F[k][j]) {
            open.insert(k);
            period[k]++;
          }
      }
    if (open.size() != n) continue;
    int profit = 0;
    for (int k = (0); k < (n); ++k) profit += P[k][period[k]];
    res = max(res, profit);
  }
  cout << res << endl;
}
