Disclosed is a compound represented by the formula (I) below, which has a glucokinase-activating effect and is thus useful for treatment of diabetes or obesity, or a pharmaceutically acceptable salt thereof. In the formula, R 1 represents an aryl or the like; R 1 represents an aryl or the like; R 2 represents a formyl or the like, R 3 represents a C 1-6 alkyl or the like; R 3 represents a hydrogen atom or the like; Z 1 represents -O- or the like; Z 2 represents -O- or the like; Y 1 - Y 4 respectively represent a carbon atom or a nitrogen atom; ring A represents a heteroaryl group; X represents a carbon atom or the like; m represents an integer of 0-2; and q represents an integer of 0-2.