#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main()
{
  int N;
  int f[105][10];
  int p[105][10];

  cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) cin >> f[i][j];
  }

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= 10; ++j) cin >> p[i][j];
  }

  auto slv = [&](bitset<10> bit) {
    i64 ans = 0;
    for (int i = 0; i < N; ++i) {

      int cnt = 0;
      for (int j = 0; j < 10; ++j) {
        if (f[i][j] && bit[j]) ++cnt;
      }

      ans += p[i][cnt];
    }
    return ans;
  };

  i64 ans = -LINF;
  for (int i = 1; i < (1 << 10); ++i) {
    chmax(ans, slv(i));
  }

  cout << ans << endl;

  return 0;
}

#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main()
{
  int N;
  int f[105][10];
  int p[105][10];

  cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) cin >> f[i][j];
  }

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= 10; ++j) cin >> p[i][j];
  }

  auto slv = [&](bitset<10> bit) {
    i64 ans = 0;
    for (int i = 0; i < N; ++i) {

      int cnt = 0;
      for (int j = 0; j < 10; ++j) {
        if (f[i][j] && bit[j]) ++cnt;
      }

      ans += p[i][cnt];
    }
    return ans;
  };

  i64 ans = -LINF;
  for (int i = 1; i < (1 << 10); ++i) {
    chmax(ans, slv(i));
  }

  cout << ans << endl;

  return 0;
}

