#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;
}
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int n, f[110][10], p[110][10], cnt[110], ans = -(1 << 28);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  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 <= (int)(10); ++j) cin >> p[i][j];
  for (int bit = 1; bit < (1 << 10); ++bit) {
    fill(cnt, cnt + n, 0);
    for (int i = 0; i < (10); ++i) {
      if ((bit >> i) & 1) {
        for (int j = 0; j < (n); ++j)
          if (f[j][i]) cnt[j]++;
      }
    }
    int sum = 0;
    for (int i = 0; i < (n); ++i) {
      sum += p[i][cnt[i]];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
