#include <bits/stdc++.h>

using namespace std;

int f[100][10], p[100][11];
int main()
{
	int n;
	cin >> 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 < 11; j++)
			scanf("%d", p[i] + j);
	int m = -2000000000;
	for (int i = 1; i < 1024; i++) {
		int P = 0;
		for (int j = 0; j < n; j++) {
			int c = 0;
			for (int k = 0; k < 10; k++)
				c += (i & 1 << k) && f[j][k];
			P += p[j][c];
		}
		m = max(m, P);
	}
	cout << m << endl;
	return 0;
}
