#include <bits/stdc++.h>
using namespace std;
long long op[100][10], n, pro[100][11], jo[10], ans = 0;
void cal() {
  bool ex = true;
  for (long long i = 0; i < 10; i++) {
    if (jo[i]) {
      ex = false;
    }
  }
  if (ex) {
    return;
  }
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    long long cnt = 0;
    for (long long j = 0; j < 10; j++) {
      if (jo[j] == 1 && op[i][j] == 1) {
        cnt++;
      }
    }
    sum += pro[i][cnt];
  }
  ans = max(sum, ans);
}
void dep(long long now) {
  if (now == 10) {
    cal();
    return;
  }
  jo[now] = 1;
  dep(now + 1);
  jo[now] = 0;
  dep(now + 1);
}
int main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) {
      cin >> op[i][j];
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j <= 10; j++) {
      cin >> pro[i][j];
    }
  }
  dep(0);
  cout << ans;
  return 0;
}
