#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
long long f[110][110];
long long p[110][110];
long long d[110];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      cin >> f[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  long long maxs = -9999;
  for (int s = 1; s < (1 << 10); s++) {
    for (int i = 1; i <= n; i++) {
      d[i] = 0;
      for (int j = 1; j <= 10; j++) {
        if (f[i][j] << (j - 1) & s) {
          d[i]++;
        }
      }
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += p[i][d[i]];
    }
    maxs = max(maxs, ans);
  }
  cout << maxs << endl;
  return 0;
}
