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