Disclosed is a compound which is useful as an 11β-hydroxysteroid dehydrogenase type 1 inhibitor.A compound represented by the formula:its pharmaceutically acceptable salt, or a solvate thereof,wherein Ring A is a group represented by the formula:Ring B is optionally substituted heteroaryl, provided that optionally substituted isoxazole is excluded, or optionally substituted heterocycle,R1 is hydrogen or optionally substituted alkyl,R2 is —OR5, —SR5, halogen, halogenated alkyl or the like,R3 is optionally substituted alkyl or the like,R4 is optionally substituted alkyl or the like,R5 is optionally substituted alkyl or the like,R6 is hydrogen or the like,R7 and R8 are each independently hydrogen or the like,R10 and R11 are each independently hydrogen or the like,R12 is optionally substituted alkyl or the like,m and p are each independently integer of 1 to 3.