#include <stdio.h>
#include <algorithm>

int main(){
	int n, F[100][10], P[100][11];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 10; j++)
			scanf("%d", &F[i][j]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= 10; j++)
			scanf("%d", &P[i][j]);

	int max = -1e9;
	for (int i = 1; i < (0x1 << 10); i++) {
		int count[100] = { 0 };
		for (int j = 0; j < n; j++)
			for (int k = 0; k < 10; k++)
				count[j] += (i >> k) & F[j][k];
		int score = 0;
		for (int j = 0; j < n; j++)
			score += P[j][count[j]];
		max = std::max(score, max);
	}
	printf("%d\n", max);
}