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

int main() {
	int n;
	cin >> n;
	int f[110] = {};
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < 10;j++) {
			int a;
			cin >> a;
			f[i] += a << (9 - j);
		}
	}
	int p[n][11];
	for (int i = 0;i < n;i++) {
		for (int j = 0;j <= 10;j++) {
			cin >> p[i][j];
		}
	}
	int ans = -1e9;
	for (int i = 1;i < (1 << 10);i++) {
		int cost = 0;
		for (int j = 0;j < n;j++) {
			cost += p[j][__builtin_popcount(f[j] & i)];
		}
		ans = max(ans, cost);
	}
	cout << ans << endl;
}