#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
long long factorial(long long n) {
  long long t = 1;
  for (long long(i) = 1; (i) <= (n); ++(i)) t *= i;
  return t;
}
long long combinations(long long n, long long k) {
  long long r = 1;
  for (long long d = 1; d <= k; ++d) {
    r *= n--;
    r /= d;
  }
  return r;
}
int main() {
  int n;
  long long ans = -1e9, cnt1, cnt2;
  cin >> n;
  vector<vector<int> > f(n, vector<int>(10));
  vector<vector<long long> > p(n, vector<long long>(11));
  for (long long(i) = 0; (i) < (n); ++(i)) {
    for (long long(j) = 0; (j) < (10); ++(j)) {
      cin >> f.at(i).at(j);
    }
  }
  for (long long(i) = 0; (i) < (n); ++(i)) {
    for (long long(j) = 0; (j) < (11); ++(j)) {
      cin >> p.at(i).at(j);
    }
  }
  for (long long(i) = 1; (i) <= ((1 << 10) - 1); ++(i)) {
    cout << bitset<11>(i) << endl;
    cnt1 = 0;
    for (long long(j) = 0; (j) < (n); ++(j)) {
      cnt2 = 0;
      for (long long(k) = 0; (k) < (10); ++(k)) {
        if ((i >> k) & 1 && f.at(j).at(k)) ++cnt2;
      }
      cnt1 += p.at(j).at(cnt2);
    }
    ans = max(ans, cnt1);
  }
  cout << ans << endl;
  return 0;
}
