#include <bits/stdc++.h>
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;
}
const long long MOD = 1000000007;
using namespace std;
map<long long, long long> mp;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
class Union_Find {
 private:
  vector<long long> par;
  vector<long long> rank;

 public:
  Union_Find(long long n) {
    for (long long i = 0; i < (n); i++) {
      par.push_back(i);
      rank.push_back(0);
    }
  }
  long long find(long long x) {
    if (par.at(x) == x)
      return x;
    else
      return par.at(x) = find(par.at(x));
  }
  void unite(long long x, long long y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank.at(x) < rank.at(y)) {
      par.at(x) = y;
    } else {
      par.at(y) = x;
      if (rank.at(x) == rank.at(y)) rank.at(x)++;
    }
  }
  bool same(long long x, long long y) { return find(x) == find(y); }
};
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long f[n][10], p[n][11];
  for (long long i = 0; i < (n); i++)
    for (long long j = 0; j < (10); j++) cin >> f[i][j];
  for (long long i = 0; i < (n); i++)
    for (long long j = 0; j < (11); j++) cin >> p[i][j];
  long long ans = -1000000000000000000;
  for (long long i = 1; i < (1 << 10); i++) {
    long long cc = 0;
    for (long long j = 0; j < n; j++) {
      long long c = 0;
      for (long long k = 0; k < (10); k++) {
        if (i && (1 << k) and f[j][k] == 1) c++;
      }
      cc += p[j][c];
    }
    chmax(ans, cc);
  }
  cout << ans << endl;
  return 0;
}
