A compound of formula (IV) that is useful for modulating a pharmacodynamic response from opioid receptors centrally and/or peripherally is disclosed, wherein: Z, A, B, D, R, R1, R2, Q, and n are as described in the specification. These compounds are suitable for treating chronic and acute pain.