#include <iostream>
#include <algorithm>
using namespace std;

int n, f[1009][19], c[1009][19], minx = -1000000000;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) cin >> f[i][j];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= 10; j++) cin >> c[i][j];
	}
	for (int i = 1; i < (1 << 10); i++) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			int s = 0;
			for (int k = 0; k < 10; k++) {
				if ((i / (1 << k)) % 2 == 1 && f[j][k] == 1) s++;
			}
			sum += c[j][s];
		}
		minx = max(minx, sum);
	}
	cout << minx << endl;
	return 0;
}