using namespace std;
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
 
int main(){
  int n;
  cin >> n;
  vector<vector<int>> F(n,vector<int>(10,0));
  // vector<vector<vector<int>>> F(n,vector<vector<int>>(5,vector<int>(2,0)));
  rep(i,n)rep(j,10)cin>>F.at(i).at(j);
  vector<vector<int>> P(n,vector<int>(11));
  rep(i,n)rep(j,11)cin>>P.at(i).at(j);
 
  ll ans = -INF;//最大値を求める。
  //joshinoお姉ちゃんの見せの時間
  for(int bit = 1; bit < (1<<10); bit++){
    vector<int> num(10,0);
    for(int i = 0; i < 10; i++){//10の時間
      if(bit&(1<<i)){//joshino open
        for(int j = 0; j < n; j++){
          if(F.at(j).at(i))num.at(j)++;
        }
      }
    }
    ll tmp = 0;
    rep(i,n){
      tmp+=P.at(i).at(num.at(i));
    }
    if(bit==1)ans = tmp;
    else ans = max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}