#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
int former(const vector<T> &v, T x) {
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
template <class T>
int latter(const vector<T> &v, T x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const long long LLINF = 1LL << 60;
const int INTINF = 1 << 29;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
  vector<long long> par;
  UnionFind(long long n) : par(n, -1) {}
  void init(long long n) { par.assign(n, -1); }
  long long root(long long x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }
  bool issame(long long x, long long y) { return root(x) == root(y); }
  bool merge(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  long long size(long long x) { return -par[root(x)]; }
};
template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T> > > &G) {
  const T INF = numeric_limits<T>::max();
  using P = pair<T, int>;
  int n = G.size();
  vector<T> d(n, INF);
  vector<int> b(n, -1);
  priority_queue<P, vector<P>, greater<P> > q;
  d[s] = 0;
  q.emplace(d[s], s);
  while (!q.empty()) {
    P p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (auto &e : G[v]) {
      int u = e.first;
      T c = e.second;
      if (d[u] > d[v] + c) {
        d[u] = d[v] + c;
        b[u] = v;
        q.emplace(d[u], u);
      }
    }
  }
  return d;
}
vector<vector<int> > bfs(vector<string> &s, int sy, int sx, char wall,
                         int dir) {
  int h = s.size(), w = s.front().size();
  vector<vector<int> > dp(h, vector<int>(w, -1));
  using P = pair<int, int>;
  queue<P> q;
  dp[sy][sx] = 0;
  q.emplace(sy, sx);
  int dy[] = {1, -1, 0, 0, 1, 1, -1, -1};
  int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
  auto in = [&](int y, int x) { return 0 <= y && y < h && 0 <= x && x < w; };
  while (!q.empty()) {
    int y, x;
    tie(y, x) = q.front();
    q.pop();
    for (int k = 0; k < dir; k++) {
      int ny = y + dy[k], nx = x + dx[k];
      if (!in(ny, nx) || s[ny][nx] == wall) continue;
      if (~dp[ny][nx]) continue;
      dp[ny][nx] = dp[y][x] + 1;
      q.emplace(ny, nx);
    }
  }
  return dp;
}
std::vector<long long> divisor(long long n) {
  std::vector<long long> ret;
  for (long long i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i != 1 && i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, F[101][11], P[101][11];
int main(void) {
  cin >> N;
  for (long long i = 0, i_len = (N); i < i_len; ++i)
    for (long long j = 0, j_len = (10); j < j_len; ++j) cin >> F[i][j];
  for (long long i = 0, i_len = (N); i < i_len; ++i)
    for (long long j = 0, j_len = (11); j < j_len; ++j) cin >> P[i][j];
  int ans = -INTINF;
  for (long long msk = 1, msk_len = (1 << 10); msk < msk_len; ++msk) {
    int sm = 0;
    for (long long i = 0, i_len = (N); i < i_len; ++i) {
      int c = 0;
      for (long long j = 0, j_len = (10); j < j_len; ++j)
        if (msk & (1 << j))
          if (F[i][j]) c++;
      sm += P[i][c];
    }
    ans = max(ans, sm);
  }
  cout << ans << endl;
}
