The present invention provides a compound represented by the formula
wherein R1 is a hydrocarbon group optionally having substituent(s), amino optionally having substituent(s), hydroxy optionally having a substituent or a heterocyclic group optionally having substituent(s); R2 is a hydrogen atom or a hydrocarbon group optionally having substituent(s); Xa and Xb are each C, N, O or S; Xc and Xd are each C or N; m is 0-2; n is 1-3; ring A is a 5-membered ring optionally having substituent(s); ring B is a 6-membered ring optionally having substituent(s); and ring C is a 3- to 5-membered ring optionally having substituent(s), provided that when Xa, Xc and Xd are each C, then Xb is N or S, or a salt thereof, which is useful as an agent for the prophylaxis or treatment of a disease relating to an action of melatonin, and the like.