  Aromatic compounds form an unusual kind of hydrogen bond with water and
ammonia molecules, known as the $\pi$-hydrogen bond. In this work, we report ab
initio path integral molecular dynamics simulations enhanced by
machine-learning potentials to study the structural, dynamical, and
spectroscopic properties of solutions of benzene in liquid water and ammonia.
Specifically, we model the spatial distribution functions of the solvents
around the benzene molecule, establish the $\pi$-hydrogen bonding interaction
as a prominent structural motive, and set up existence criteria to distinguish
the $\pi$-hydrogen bonded configurations. These serve as a structural basis to
calculate binding affinities of the solvent molecules in $\pi$hydrogen bonds,
identify an anticooperativity effect across the aromatic ring in water (but not
ammonia), and estimate $\pi$-hydrogen bond lifetimes in both solvents. Finally,
we model hydration-shell-resolved vibrational spectra to clearly identify the
vibrational signature of this structural motif in our simulations. These
decomposed spectra corroborate previous experimental findings for benzene in
water, offer additional insights, and further emphasize the contrast between
$\pi$-hydrogen bonds in water and in ammonia. Our simulations provide a
comprehensive picture of the studied phenomenon and, at the same time, serve as
a meaningful \textit{ab initio} reference for an accurate description of
$\pi$-hydrogen bonding using empirical force fields in more complex situations,
such as the hydration of biological interfaces.
