#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 100 + 10;
long long F[maxn][maxn];
long long P[maxn][maxn];
long long D[maxn];
int main() {
  long long n;
  while (scanf("%lld", &n) == 1) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= 10; j++) scanf("%lld", &F[i][j]);
    for (int i = 1; i <= n; i++)
      for (int j = 0; j <= 10; j++) scanf("%lld", &P[i][j]);
    long long Max = -1 * INF;
    memset(D, 0, sizeof(D));
    for (int s = 1; s < (1 << 10); s++) {
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= 10; j++) {
          if (F[i][j] & s) D[i]++;
        }
      }
      long long ans = 0;
      for (int i = 1; i <= n; i++) ans += P[i][D[i]];
      Max = max(Max, ans);
    }
    cout << Max << endl;
  }
}
