#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int bitsNum(int bits)
{
	bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
	bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
	bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
	bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
	return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}

int main() {

	int N;
	int F[123];
	int P[123][16];

	scanf("%d", &N);

	rep(i, N) {
		F[i] = 0;
		rep(j, 10) {
			int t;
			scanf("%d", &t);
			F[i] <<= 1;
			F[i] += t;
		}
	}

	rep(i, N) {
		rep(j, 11) {
			scanf("%d", &P[i][j]);
		}
	}

	long long int ans = (-9223372036854775807i64 - 1);
	rep(i, 1 << 10) {
		if (!i) continue;
		long long int t = 0;
		rep(j, N) {
			t += P[j][bitsNum(F[j] & i)];
		}
		ans = max(ans, t);
	}

	printf("%lld", ans);

	return 0;
}