#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
const long long INF = 1LL << 60;
using vll = vector<long long>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pair<long long, long long> = pair<long long, long long>;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  long long n;
  cin >> n;
  vvll table(n, vll(10));
  for (long long i = 0; i < (n); i++)
    for (long long j = 0; j < (10); j++) cin >> table[i][j];
  vvll p(n, vll(11));
  for (long long i = 0; i < (n); i++)
    for (long long j = 0; j < (11); j++) cin >> p[i][j];
  long long ans = 0;
  for (int bit = 1; bit < (1 << 10); bit++) {
    long long cu = 0;
    vll pp(10);
    for (long long i = 0; i < (10); i++) {
      if (bit & (1 << i)) pp[i] = 1;
    }
    for (long long i = 0; i < (n); i++) {
      long long k = 0;
      for (long long j = 0; j < (10); j++) {
        if (pp[j] && table[i][j]) {
          k++;
        }
      }
      cu += p[i][k];
    }
    ans = max(ans, cu);
  }
  cout << (ans) << endl;
}
