//#pragma GCC diagnostic error "-std=c++11"
#include <bits/stdc++.h>
using namespace std;
#include<iostream>
#include<bitset>
using namespace std;
typedef bitset<12> bit;
const int N=107;
int n,i,j,m,mp[N][12],x,ans=-2e9,res;
bit s[N],tmp;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	for(cin>>n,i=1;i<=n;++i)for(j=0;j<10;++j)cin>>x,s[i][j]=x;
	for(i=1;i<=n;++i)for(j=0;j<=10;++j)cin>>mp[i][j];
	for(m=(1<<10)-1,i=1;i<=m;++i){
		tmp=bit(i);
		for(res=0,j=1;j<=n;++j)res+=mp[j][(tmp&s[j]).count()];
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}