#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<stdio.h>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<vector<int>> F(N, vector<int>(10, 0));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 10; j++) {
			//cin >> F[i][j];
			scanf_s("%d", &F[i][j]);
		}
	}

	vector<vector<Int>> P(N, vector<Int>(11, 0));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 11; j++) {
			cin >> P[i][j];
		}
	}

	Int ans = -INF;
	Int temp;
	Int count;
	for (Int bit = 1; bit < (1LL<<10); bit++) {
		temp = 0;
		for (Int i = 0; i < N; i++) {
			count = 0;
			for (Int j = 0; j < 10; j++) {
				if ((bit >> j & 1) && F[i][j]) {
					count++;
				}
			}
			temp += P[i][count];
		}
		ans = max(ans, temp);
	}

	cout << ans << endl;
}