The present invention provides a fused heterocycle derivative having a strong Smo inhibitory activity, and use thereof.Specially, the present invention relates to a compound represented by the formulawherein each symbol is as defined in the specification,or salt thereof, and a medicament containing the compound or a prodrug thereof, which is an Smo inhibitor or an agent for the prophylaxis or treatment of cancer.