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

int main()
{
	int n;
	cin >> n;
	auto f = vector<vector<int>>(n, vector<int>(10));
	auto p = vector<vector<int>>(n, vector<int>(11));
	for(auto&& g : f) for(auto&& h : g) cin >> h;
	for(auto&& q : p) for(auto&& r : q) cin >> r;
	int ans = -1000000007;
	for(auto i = 1; i < 1 << 10; ++i){
		int sum = 0;
		for(auto j = 0; j < n; ++j){
			int cnt = 0;
			for(auto k = 0, t = i; k < 10 && t > 0; ++k, t >>= 1){
				if(t % 2 && f[j][k]) ++cnt;
			}
			sum += p[j][cnt];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}