The present invention provides a compound of formula (I) wherein X, Y, Z1, Z2, R1, R2, A, B, p and q are as disclosed in the specification. A pharmaceutical composition and a method for modulating the Hedgehog pathway are also provided. The present invention further provides a process for preparing the compound.