A compound of formula (A); wherein ring A is an aromatic ring or a heteroaromatic ring; R1 is independently halogen, cyano, etc., each of X1, X2 and X3 is CR2 or nitrogen, R2 is independently hydrogens, etc., n is 0, 1, 2, 3 or 4; -D-Y is -O-CH2COOH, etc, and G is a substituted amino, a substituted heterocyclic group, etc, or a pharmaceutical acceptable salt thereof, has activities of opening BK channels.