#include <bits/stdc++.h>
using namespace std;
template <typename H>
bool chmin(H& v1, const H v2) {
  if (v1 > v2) {
    v1 = v2;
    return true;
  }
  return false;
}
template <typename H>
bool chmax(H& v1, const H v2) {
  if (v1 < v2) {
    v1 = v2;
    return true;
  }
  return false;
}
template <typename H>
void read(H& head) {
  cin >> head;
}
template <typename H, typename... T>
void read(H& head, T&... tail) {
  cin >> head;
  read(tail...);
}
template <typename H>
void write(H head) {
  cout << head << '\n';
}
template <typename H, typename... T>
void write(H head, T... tail) {
  cout << head << " ";
  write(tail...);
}
template <typename... T>
void die(T... tok) {
  write(tok...);
  exit(0);
}
int f[105][10], p[105][11];
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n;
  read(n);
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (10); ++j) read(f[i][j]);
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (11); ++j) read(p[i][j]);
  long long ans = 0;
  for (int b = 0; b < (1 << 10); ++b) {
    long long val = 0;
    for (int i = 0; i < (n); ++i) {
      int cnt = 0;
      for (int j = 0; j < (10); ++j)
        if (b & (1 << j) && f[i][j]) cnt++;
      val += p[i][cnt];
    }
    chmax(ans, val);
  }
  write(ans);
}
