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

int main() {
	int N; cin >> N;
	vector<vector<int>>F(N, vector<int>(10));
	vector<vector<int>>P(N, vector<int>(11));
	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 < 11; j++)cin >> P[i][j];

	int ans = INT32_MIN;
	for (int i = 1; i < pow(2, 10); i++) {
		vector<char>used(10);
		for (int j = 0; j < 10; j++)used[j] = (i>>j) & 1;

		vector<int>cnt(N);
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < N; k++) {
				if (used[j] && F[k][j])cnt[k]++;
			}
		}

		int sum = 0;
		for (int j = 0; j < N; j++)sum += P[j][cnt[j]];
		ans = max(ans , sum);
	}

	cout << ans << endl;
	
	return 0;
}