Effective hamiltonian for nonleptonic B̄ or Λb decays to final states with two charmed hadrons