#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
  int n;
  cin >> n;
  vector<vector<int>> f(n,vector<int>(10));
  vector<vector<int>> p(n,vector<int>(11));
  rep(i,n){
    rep(j,10) cin >> f[i][j];
  }
  rep(i,n){
    rep(j,11) cin >> p[i][j];
  }
  vector<int> a(10);
  a={1,2,4,8,16,32,64,128,256,512};
  
  int ans=-1000000000;
  for(int m=1;m<1024;m++){
    int an=0;
    rep(i,n){//店i
      int q=0;
      rep(j,10){
        if(f[i][j]&&(int)(m/a[j]%2)) q++;
      }
      an+=p[i][q];
    }
    ans=max(ans,an);
  }
  cout << ans << endl;
}