Meson production in pA and AA collisions at AGS energies