#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long f[N];
  for (long long i = 0; i < N; i++) {
    long long num = 0;
    for (long long j = 0; j < 10; j++) {
      long long x;
      cin >> x;
      num += x << j;
    }
    f[i] = num;
  }
  long long P[N][11];
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j <= 10; j++) {
      cin >> P[i][j];
    }
  }
  long long res = -1e9;
  for (long long bits = 0; bits < 1 << 10; bits++) {
    long long num = 0;
    for (long long i = 0; i < N; i++) {
      long long x = __builtin_popcountll(bits & f[i]);
      num += P[i][x];
    }
    res = max(res, num);
  }
  cout << res << endl;
}
