#include <bits/stdc++.h>
using namespace std;
int b[1020];
int c[1020][12];
int n, x;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			scanf("%d", &x);
			b[i] |= x << j;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= 10; j++) {
			scanf("%d", &c[i][j]);
		}
	}
	int ans = -1e9;
	for (int u = 1; u < 1024; u++) {
		int tmp = 0;
		for (int i = 0; i < n; i++) {
			int cnt = __builtin_popcount(b[i] & u);
			tmp += c[i][cnt];
		}
		ans = max(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}