#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}

int main(){
	int N;
	cin >> N;
	vector<vector<int>> F,P;
	vector<int> vec;
	rep(i,N){
		vec = getv<int>(10);
		F.emplace_back(vec);
	}
	rep(i,N){
		vec = getv<int>(11);
		P.emplace_back(vec);
	}
	int max = -1e7 * 10;
	int sum = 0;
	int cntr[N] = {};
	for(int i=1; i<1024; i++){
		string joisino = bitset<10>(i).to_string();
		rep(i,N){
			rep(j,10) if(F[i][j]==1 && joisino[j]=='1') cntr[i]++;
			sum += P[i][cntr[i]];
		}
		if(sum > max) max = sum;
		rep(i,N) cntr[i] = 0;
		sum = 0;
	}
	cout << max << endl;
}