#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll f[111][11];
ll p[111][12];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++)cin>>f[i][j];
  }
  ll ans=-llINF;
  for(int i=0;i<n;i++)
    for(int j=0;j<11;j++)cin>>p[i][j];
  for(int i=1;i<BITLE(10);i++){
    ll sum=0;
    for(int k=0;k<n;k++){
      ll cnt=0;
      for(int j=0;j<10;j++){
	for(i&BITLE(j)&&f[k][j]){
	  cnt++;
	}	
      }
      sum+=p[k][cnt];
    }
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}
