#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10)), p(n, vector<int>(10, 0));
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(10); j++) cin >> f[i][j];
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(11); j++) cin >> p[i][j];
  ll ans = -1e9;
  for (int si = 1; si < (1 << 10); si++) {
    vector<int> d(10);
    for (int i = 0; i < (int)(10); i++) d[i] = (si >> i & 1);
    ll profit = 0;
    for (int i = 0; i < (int)(n); i++) {
      ll c = 0;
      for (int j = 0; j < (int)(10); j++)
        if (d[j] == 1 && f[i][j] == 1) c++;
      profit += p[i][c];
    }
    ans = max(ans, profit);
  }
  cout << ans << endl;
  return 0;
}
