#include <bits/stdc++.h>
using namespace std;

int main(){
	int N;
	cin >> N;
	int F[N] = {0}, P[N][11];
	int ans = -110000007;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 10; j++){
			int tmp;
			cin >> tmp;
			if(tmp)
				F[i] |= (1<<j);
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 11; j++){
			cin >> P[i][j];
		}
	}

	for(int bit = 1; bit < (1<<10); bit++){
		int pro = 0;
		for(int i = 0; i < N; i++){
			int c = __builtin_popcount(bit & F[i]);
			pro += P[i][c];
		}
		ans = max(ans,pro);
	}
	cout << ans << endl;
	return 0;
}