#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int f[200][10];
int p[200][20];

signed main(){
	int n;scanf("%d",&n);
	rep(i,n)rep(j,10)scanf("%d",&f[i][j]);
	rep(i,n)rep(j,11)scanf("%d",&p[i][j]);
	int Max=INT_MIN;
	rep(i,1<<10){
		if(i==0)continue;
		int ans=0;
		rep(j,n){
			int cnt=0;
			rep(k,10){
				if((i>>k&1)&&f[j][k]==1)cnt++;
			}
			ans+=p[j][cnt];
		}
		Max=max(Max,ans);
	}
	cout<<Max<<endl;
}