#include<bits/stdc++.h>
using namespace std;
 
// #define DEBUG
#define fi first
#define se second
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)    //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
typedef long long LL;
typedef unsigned int UINT;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector< Vi > VVi;
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(P *a){scanf("%d",&a->fi);scanf("%d",&a->se);} 
void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
void SCAN(UINT *a,int n){int i;REP(i,n){scanf("%u",&a[i]);}}  //scan for type unsigned int array
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int MOD = 1000000007;
const int INF = 1999999999;
const LL INFLL = 999999999999999;
 
const int DX4[4]= {-1,0,1,0};
const int DY4[4]= {0,-1,0,1};
 
//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
	fill((T*)array,(T*)(array+N),val);
}
 
long double pascalTri(int n,int r){
	long double tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]+tri[i-1][j]);}
		}
	}
	return tri[n][r];
}
 
LL GCD(LL a,LL b){
	LL t;
	if(a<b){t=a;a=b;b=t;}
	if(b==0){return a;}
	LL r;
	while(a%b!=0){
		r=a%b;
		a=b;
		b=r;
	}
	return b;
}
 
LL LCM(LL a,LL b){
	LL ab=(a*b)%MOD;
	return ab/GCD(a%b,b);
}
 
double area(P a,P b,P c){
	return ((b.fi-a.fi)*(c.se-a.se)-(b.se-a.se)*(c.fi-a.fi))/2.;
}
 
int checkCross(P v1,P v2,P a,P b){
	// cout<<area(v1)<<" "<<area(v2)<<endl;
	if(area(a,b,v1)*area(a,b,v2)>=0){return 0;}
	if(area(v1,v2,a)*area(v1,v2,b)>=0){return 0;}
	return 1;
}
 
 
 

int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int n;
	int a,b;
	int k;
	int i,j,r;

	SCAN(&n);
	int f[n][10];
	LL p[n][11];
	REP(i,n){
		SCAN(f[i],10);
	}
	REP(i,n){
		SCAN(p[i],11);
	}

	#ifdef DEBUG
		auto start=chrono::system_clock::now();
	#endif
 

	int ft[105];
	LL sum=-INF;
	LL temp;
	int stnum;
	REP(i,(1<<10)){
		FILL(ft,0);
		j=0;
		
		while((i>>j)!=0){
			// cout<<(i>>j)%2;
			if((i>>j)%2==1){
				REP(k,n){
					if(f[k][j]==0){continue;}
					ft[k]++;
				}
			}
			j++;
		}

		stnum=0;
		REP(k,n){
			if(ft[k]!=0){continue;}
			stnum++;
		}
		if(stnum==n){continue;}
		temp=0;
		REP(k,n){
			// cout<<" "<<ft[k]<<" ";
			temp+=p[k][ft[k]];
		}
		// if(sum<temp){
		// 	j=0;
		// 	while((i>>j)!=0){
		// 		cout<<(i>>j)%2;
		// 		j++;
		// 	}
		// 	cout<<" ft";
		// 	REP(k,n){
		// 		cout<<" "<<ft[k]<<" ";
		// 	}
		// 	cout<<" p";
		// 	REP(k,n){
		// 		cout<<" "<<p[k][ft[k]]<<" ";
		// 	}
		// 	cout<<endl;
		// }
		sum=max(sum,temp);
	}
	

	printf("%d\n",sum);
 
	
 
	#ifdef DEBUG
		auto end=chrono::system_clock::now();
		cout<<"Elapsed time : "<<chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms."<<endl;
	#endif
	return 0;
}

Measured memory_bytes: 256