#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<long long>>;
const long long MOD = 1000000007;
const double PI = 3.1415926535897932;
const long long INF = 1 << 29;
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
long long n;
int solve() {
  cin >> n;
  vector<vector<long long>> f(n, vector<long long>(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[i][j];
    }
  }
  for (long long i = (0); i < (n); i++) {
    for (long long j = (0); j < (11); j++) {
      cin >> p[i][j];
    }
  }
  long long ans = INF * (-1);
  for (long long i = 1; i < 1 << 10; ++i) {
    vector<long long> open(10);
    long long tmp = i;
    long long count = 0;
    while (tmp > 0) {
      open[count] = tmp % 2;
      tmp /= 2;
      count++;
    }
    vector<long long> count_v(n);
    for (long long j = (0); j < (n); j++) {
      count_v[j] = 0;
    }
    long long ans_tmp = 0;
    for (long long j = (0); j < (n); j++) {
      for (long long k = (0); k < (10); k++) {
        if (f[j][k] == open[k] && f[j][k] == 1) {
          count_v[j]++;
        }
      }
      ans_tmp += p[j][count_v[j]];
    }
    if (ans < ans_tmp) {
      ans = ans_tmp;
    }
  }
  cout << ans << endl;
  return 0;
}
int main() {
  cout << std::fixed << std::setprecision(10);
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int end_solve = solve();
  return end_solve;
}
