#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  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];
  vector<vector<int>> p(n, vector<int>(11));
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (11); ++j) cin >> p[i][j];
  int ans = -200000000;
  for (int i = 1; i < (1 << 10); ++i) {
    vector<int> c(n, 0);
    for (int j = 0; j < (n); ++j) {
      for (int k = 0; k < (10); ++k) {
        if ((i & (1 << k)) && f[j][k]) {
          c[j]++;
        }
      }
    }
    int sum = 0;
    for (int j = 0; j < (n); ++j) {
      sum += p[j][c[j]];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
