#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i) continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll ceil(ll a, ll b) { return (a + b - 1) / b; }
const ll INF = LONG_MAX;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using Graph = vector<vector<int>>;
vector<bool> seen;
void dfs(const Graph &g, int v) {
  seen[v] = true;
  for (auto next_v : g[v]) {
    if (seen[next_v]) continue;
    dfs(g, next_v);
  }
}
struct node {
  int to, weight;
};
using Edge = vector<node>;
void addEdge(bool directed, Edge *edges, int u, int v, int wt) {
  edges[u].push_back({v, wt});
  if (!directed) {
    edges[v].push_back({u, wt});
  }
}
int pre_node[100000];
void zeroOneBFS(Edge *edges, vector<int> &dist, int src) {
  for (int i = 0; i < dist.size(); i++) dist[i] = INT_MAX;
  deque<int> Q;
  dist[src] = 0;
  Q.push_back(src);
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop_front();
    for (int i = 0; i < edges[v].size(); i++) {
      if (dist[edges[v][i].to] > dist[v] + edges[v][i].weight) {
        dist[edges[v][i].to] = dist[v] + edges[v][i].weight;
        pre_node[edges[v][i].to] = v;
        if (edges[v][i].weight == 0)
          Q.push_front(edges[v][i].to);
        else
          Q.push_back(edges[v][i].to);
      }
    }
  }
  for (int i = 0; i < dist.size(); i++) cout << dist[i] << " ";
}
bitset<3> is_prime;
void SieveOfEratosthenes(const int n) {
  for (int i = 2; i <= n; i++) is_prime.set(i);
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      for (int j = i * 2; j <= n; j += i) {
        is_prime.reset(j);
      }
    }
  }
}
vector<ll> sonum(10000001, -1);
void prime_factorize(long long N) {
  if (N < 4) return;
  ll oriN = N;
  ll res = 0;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0;
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    res += ex;
    if (sonum[N] != -1) {
      res += sonum[N];
      break;
    }
  }
  if (N != 1) res++;
  sonum[oriN] = res;
}
int main() {
  const int slot = 10;
  int n;
  cin >> n;
  int f[101][100];
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)10; j++) {
      cin >> f[i][j];
    }
  }
  int p[101][100];
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)10; j++) {
      cin >> p[i][j];
    }
  }
  int ans = -1000000000;
  for (int i = 1; i < (1 << slot); i++) {
    vector<bool> jopen(slot, false);
    for (int j = 0; j < (int)slot; j++) {
      jopen[j] = (i & 1 << j) ? true : false;
    }
    int ans_tmp = 0;
    for (int shop = 0; shop < (int)n; shop++) {
      int sum = 0;
      int same = 0;
      for (int time = 0; time < (int)10; time++) {
        if (f[shop][time] == 1 && jopen[time]) {
          same++;
        }
      }
      ans_tmp += p[shop][same];
    }
    if (ans < ans_tmp) {
      ans = ans_tmp;
    }
  }
  cout << ans;
  return 0;
}
