#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using namespace std;
bool isPrimeNum(ll x) {
  if (x <= 1) {
    return false;
  }
  int n = (int)sqrt((double)x);
  for (int i = 2; i <= n; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
ll myPow(ll x, ll n, ll m) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
constexpr ll abs(ll a, ll b) {
  if (a >= b) return a - b;
  if (a < b) return b - a;
}
constexpr ll min(ll a, ll b) {
  if (a >= b) return b;
  if (a < b) return a;
}
constexpr ll max(ll a, ll b) {
  if (a >= b) return a;
  if (a < b) return b;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct UnionFind {
  vector<int> par;
  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};
int main() {
  ll N;
  cin >> N;
  ll F[N][10];
  ll P[N][10];
  for (int i = (0); i <= (N - 1); i++) {
    for (int j = (0); j <= (9); j++) {
      cin >> F[i][j];
    }
  }
  for (int i = (0); i <= (N - 1); i++) {
    for (int j = (0); j <= (9); j++) {
      cin >> P[i][j];
    }
  }
  ll ans = -9223372036854775800;
  ll n = 10;
  for (int bit = 1; bit < (1 << n); ++bit) {
    ll tmp = 0;
    for (int j = (0); j <= (N - 1); j++) {
      ll cnt = 0;
      for (int i = 0; i < n; ++i) {
        if (bit & (1 << i) && (F[j][i]) == 1) {
          cnt++;
        }
      }
      tmp = tmp + P[j][cnt];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
