#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};
int N, F[101][101], P[101][101];
ll res = -INF;
int main(int argc, char *argv[]) {
  cin >> N;
  for (int i = 0; i < (int)N; i++)
    for (int j = 0; j < (int)10; j++) cin >> F[i][j];
  for (int i = 0; i < (int)N; i++)
    for (int j = 0; j < (int)11; j++) cin >> P[i][j];
  for (int i = 1; i < (int)1 << 10; i++) {
    ll sum = 0;
    for (int j = 0; j < (int)N; j++) {
      int c = 0;
      for (int k = 0; k < (int)10; k++)
        if (i & (1 << k) && F[i][j]) c++;
      sum += P[i][c];
    }
    res = max(res, sum);
  }
  cout << res << endl;
  return 0;
}
