#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_N = 103;
int F[MAX_N][12];
int P[MAX_N][12];
int D[MAX_N];
int N;
int mx = -1e7 - 5;
int check() {
  int cnt[N + 3];
  fill(cnt, cnt + N, 0);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j)
      if (D[j] && F[i][j]) ++cnt[i];
  }
  int res = 0;
  for (int i = 0; i < N; ++i) res += P[i][cnt[i]];
  bool flg = false;
  for (int i = 0; i < 10; ++i)
    if (D[i] == 1) {
      flg = true;
      break;
    }
  if (flg)
    return res;
  else
    return -1e7 - 10;
}
void tansaku(int cur) {
  if (cur >= 10) {
    mx = max(mx, check());
    return;
  }
  D[cur] = 1;
  tansaku(cur + 1);
  D[cur] = 0;
  tansaku(cur + 1);
}
int main() {
  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 < 11; ++j) cin >> P[i][j];
  }
  tansaku(0);
  cout << mx << endl;
  return 0;
}
