A compound of the formula: wherein X is —N═, —CH═, or the like; W is —CH2— or the like; U is —S— or the like; R1 and R2 are each independently hydrogen, halogen, optionally substituted lower alkyl, or the like; Q is a single bond or the like; R3 is hydrogen or the like; Ring A is a 6-membered aromatic heterocyclic group having 1-3 nitrogen atoms; each R4 is independently hydrogen, halogen, or the like; m is an integer from 0 to 2; G is —C(═O)— or the like; D is a single bond, —NH—, or the like; and E is a cyclic quaternary ammonium group, or an ester, a protected compound at the amino on the ring in the 7-side chain, a pharmaceutically acceptable salt, or a solvate thereof.