#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> opt;
void gen(int x, int y, vector<int> curr) {
  curr.push_back(x);
  curr.push_back(y);
  if (curr.size() == 10) {
    opt.push_back(curr);
    return;
  }
  gen(0, 1, curr);
  gen(1, 0, curr);
  gen(1, 1, curr);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> P(n, vector<int>(11));
  vector<vector<int>> F(n, vector<int>(10));
  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];
    }
  }
  gen(0, 1, vector<int>());
  gen(1, 0, vector<int>());
  gen(1, 1, vector<int>());
  long long res = -1e18;
  for (auto &o : opt) {
    int sum = 0;
    vector<int> c(n, 0);
    for (int i = 0; i < n; ++i) {
      for (int p = 0; p < 10; ++p) {
        if (o[p] == 1 && F[i][p] == 1) c[i]++;
      }
      sum += P[i][c[i]];
    }
    if (sum > res) res = sum;
  }
  cout << res << endl;
  return 0;
}
