Provided is a compound having a superior acid secretion suppressive action, which shows an antiulcer activity and the like.A compound represented by the formula (I) or a salt thereof:wherein ring A is a saturated or unsaturated 5-membered heterocycle containing, as a ring-constituting atom besides carbon atoms, at least one heteroatom selected from a nitrogen atom, an oxygen atom and a sulfur atom, the ring-constituting atoms X1 and X2 are the same or different and each is C or N, the ring-constituting atoms X3 and X4 are the same or different and each is C, N, O or S (provided that a pyrrole ring wherein X1 is N is excluded from ring A), and when the ring-constituting atom X3 or X4 is C or N, each ring-constituting atom optionally has substituent(s) selected from an optionally substituted alkyl, an acyl, an optionally substituted hydroxy, an optionally substituted mercapto, an optionally substituted amino, a halogen, a cyano and a nitro;R1 and R2 are each a cyclic group optionally having substituent(s); R3 and R4 are each H or alkyl, or R3 and R4 form, together with the adjacent N, an nitrogen-containing heterocycle; and Y is a spacer.