Disclosed is a compound which is useful as an 11.beta.-hydroxysteroiddehydrogenase type 1 inhibitor.A compound represented by the formula:(see formula (I),its pharmaceutically acceptable salt, or a solvate thereof,wherein Ring A is a group represented by the formula:(see formula II)(see formula III)(see formula IV) or(see formula V)Ring B is optionally substituted heteroaryl, provided that optionallysubstitutedisoxazole 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.