Disclosed are compounds of the following formula and their pharmaceutically-acceptablesalts, which have an effect of glucokinase activation and are useful in thefield ofmedicines for treatment for diabetes, obesity, etc.(wherein ring A represents a pyrazolyl group optionally having a lower alkylgroup, etc.; ring Brepresents a heteroaryl group; R represents a lower alkyl group, etc.; R1represents a group of aformula:(wherein R11 and R12 each independently represent a hydrogen atom, etc.; mindicates aninteger of from 2 to 6), etc.;R2 represents a lower alkyl group, etc.; r indicates an integer of from 0 to3; k indicates aninteger of from 0 to 4).