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 X 1 and X 2 are the same or different and each is C or N, the ring-constituting atoms X 3 and X 4 are the same or different and each is C, N, O or S (provided that a pyrrole ring wherein X 1 is N is excluded from ring A), and when the ring-constituting atom X 3 or X 4 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; R 1 and R 2 are each a cyclic group optionally having substituent(s); R 3 and R 4 are each H or alkyl, or R 3 and R 4 form, together with the adjacent N, an nitrogen-containing heterocycle; and Y is a spacer.