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

int F[100][10];
int P[100][11];
int N;

int main()
{
	cin >> N;
	
	memset(F, 0, sizeof(F));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> F[i][j];
		}
	}
	
	memset(P, 0, sizeof(P));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 10; j++) {
			cin >> P[i][j];
		}
	}
	
	int num = 0;
	int ind = 0;

	int ans = 0;

	int max = 0;

	for (int i = 1; i <= 1024; i++) {
		ind = i;
		for (int j = 0; j < N; j++) {
			for (int k = 9; k >=0; k--) {
				num += (ind / pow(2, k)) * F[j][k];
				ind = ind % (int)pow(2, k);
			}
			ans += P[j][num];
			ind = i;
			num = 0;
		}
		if (i == 1) max = ans;
		else if (max < ans) {
			max = ans;
		}
		num = 0;
		ans = 0;
	}

	cout << max << endl;

    return 0;
}

