#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  ll f[N];
  for (ll i = 0; i < N; i++) {
    ll num = 0;
    for (ll j = 0; j < 10; j++) {
      ll x; cin >> x; num+= x << j;
    }
    f[i] = num;
  }
  ll P[N][11];
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j <= 10; j++) {
      cin >> P[i][j];
    }
  }
  ll res = -1e9;
  for (ll bits = 1; bits < 1 << 10; bits++) {
    ll num = 0;
    for (ll i = 0; i < N; i++) {
      ll x = __builtin_popcountll(bits & f[i]);
      num += P[i][x];
    }
    res = max(res,num);
  }
  cout << res << endl;
}