#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1e9 + 7;
static const long long MAX_L = (long long)1 << 62;
long long f[100][11];
long long p[100][11];
long long o[11] = {};
long long maxV = -1 << 21;
long long n;
long long calc() {
  long long sum = 0;
  for (long long s = 1; s <= n; s++) {
    long long cnt = 0;
    for (long long i = 1; i <= 11; i++) {
      if (o[i] && f[s][i]) {
        cnt++;
      }
    }
    sum += p[s][cnt];
  }
  return sum;
}
bool checkOpen() {
  bool ok = false;
  for (long long i = 1; i < 11; i++) {
    if (o[i]) {
      ok = true;
      break;
    }
  }
  return ok;
}
void dfs(long long n) {
  if (n == 11) {
    if (checkOpen()) {
      maxV = max(maxV, calc());
    }
    return;
  }
  o[n] = true;
  dfs(n + 1);
  o[n] = false;
  dfs(n + 1);
}
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= 10; j++) cin >> f[i][j];
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j < 11; j++) cin >> p[i][j];
  dfs(1);
  cout << maxV << endl;
  return 0;
}
