#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  ll f[n][10];
  ll p[n][11];
  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 = -100000000000LL;
  for (int i = 1; i < (1 << 10) - 1; i++) {
    int cur = i;
    vector<int> open(n, 0);
    int count = 0;
    while (cur > 0) {
      if ((cur & 1) == 1) {
        for (int j = 0; j < (int)(n); j++) {
          if (f[j][count] == 1) {
            open[j]++;
          }
        }
      }
      count++;
      cur = cur >> 1;
    }
    ll point = 0;
    for (int j = 0; j < (int)(n); j++) {
      point += (ll)p[j][open[j]];
    }
    if (ans < point) {
      ans = point;
    }
  }
  cout << ans << endl;
  return 0;
}
