Compounds having glucokinase activating effects and being useful as treatments for diabetes, which are represented by the following formula (I):[wherein X1 represents oxygen, etc., X2 represents oxygen, etc., R1 represents a group on Ring A such as alkylsulfonyl, etc., R2 represents C3-7 cyclic alkyl optionally substituted with a halogen, etc., R3 represents a substituent on Ring B such as lower alkyl, etc., formula (II):[Chemical Formula 1]represents 6- to 10-membered aryl, etc., and formula (III):[Formula 1]represents monocyclic or bicyclic heteroaryl optionally having on Ring B a substituent represented by R3 above, wherein the carbon atom of Ring B which is bonded to the nitrogen atom of the amide group of formula (I) forms a C═N bond with the nitrogen atom of the ring],as well as their pharmaceutically acceptable salts.