#include <bits/stdc++.h>
using ll = long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
int main() {
  int n;
  cin >> n;
  ll maxv = -10000005;
  vector<vector<int>> f(n, vector<int>(10, 0)), 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];
  }
  for (int bit = 0; bit < (1 << 10); ++bit) {
    vector<int> count(n, 0);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < 10; ++j) {
        if (bit & 1 << j && f[i][j] == 1) ++count[i];
      }
    }
    for (int i = 0; i < n; ++i) sum += p[i][count[i]];
    maxv = max(maxv, sum);
  }
  cout << maxv << endl;
  return 0;
}
