Disclosed are compounds of the following formula and their pharmaceutically-acceptable salts, which have an effect of glucokinase activation and are useful in the field of medicines for treatment for diabetes, obesity, etc. (wherein ring A represents a pyrazolyl group optionally having a lower alkyl group, etc.; ring B represents a heteroaryl group; R represents a lower alkyl group, etc.; R 1 represents a group of a formula: (wherein R 11 and R 12 each independently represent a hydrogen atom, etc.; m indicates an integer of from 2 to 6), etc.; R 2 represents a lower alkyl group, etc.; r indicates an integer of from 0 to 3; k indicates an integer of from 0 to 4).