#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using v = vector<ll>;
using vv = vector<v>;
int main() {
  ll n;
  cin >> n;
  vv f(n, v(10));
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (10); j++) cin >> f[i][j];
  vv p(n, v(11));
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (11); j++) cin >> p[i][j];
  ll ans = -2002002002LL;
  for (int k = 1; k < 1 << 10; k++) {
    int num = 0;
    ll now = 0;
    for (int i = 0; i < (n); i++) {
      for (int j = 0; j < (10); j++) {
        if ((k & 1 << j) && f[i][j]) num++;
      }
      now += p[i][num];
    }
    ans = max(now, ans);
  }
  cout << ans << endl;
  return 0;
}
