#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
using PPI = pair<P, int>;
ll const mod = 1e9 + 7;
const ll MAX = 1000005;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vd = vector<double>;
using vs = vector<string>;
using vp = vector<P>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<double>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<P>>;
using vvb = vector<vector<bool>>;
template <typename T>
bool chmax(T& a, const T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  vvi f(n, vi(10));
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < 10; ++j) {
      cin >> f[i][j];
    }
  }
  vvi p(n, vi(11));
  for (long long i = 0; i < n; ++i)
    for (long long j = 0; j < 11; ++j) cin >> p[i][j];
  int ans = -1e9 + 5;
  for (long long i = int(1); i < (int)(1 << 10); i++) {
    int res = 0;
    vi cnt(n);
    for (long long j = 0; j < 10; ++j) {
      if (i >> j & 1) {
        for (long long k = 0; k < n; ++k) {
          if (f[k][j] == 1) cnt[k]++;
        }
      }
    }
    for (long long i = 0; i < n; ++i) res += p[i][cnt[i]];
    chmax(ans, res);
  }
  cout << ans << endl;
  return 0;
}
