  Water and the hydroxyl radical are major constituents of the envelope of
O-rich late-type stars. Transitions involving energy levels that are highly
excited have been observed in both H$_2$O and OH. These and more recently
discovered transitions can now be observed at a high sensitivity and angular
resolution with the ALMA Array. Spectra and maps of H$_2$O and OH observed with
an angular resolution of 20 to $\sim$200 mas were obtained at two epochs with
the ALMA array. Observations with the Compact Array were also used to check for
time variability of water transitions. Radiative transfer models of water were
revisited to characterize masing conditions and up-to-date chemical models were
used for comparison with our observations. Ten rotational transitions of H$_2$O
with energies up to 9000 K were observed in various vibrational states. All but
one are new detections in space, and from these we have derived accurate rest
frequencies. Hyperfine split $\Lambda$-doubling transitions in v = 0, J = 27/2
and 29/2 levels of the $^2\Pi_{3/2}$ state and, $J = 33/2$ and 35/2 of the
$^2\Pi_{1/2}$ state of OH with excitation energies up to 8900 K were also
observed. Four of these transitions are new detections in space. Combining our
measurements with earlier observations of OH, the v = 0 and v = 1
$\Lambda$-doubling frequencies have been improved. Our H$_2$O maps show compact
emission and extensions up to twelve stellar radii or more. The 268.149 GHz
emission line of water in the v$_2$ = 2 state is time variable, tends to be
masing with dominant radiative pumping, and is widely excited. The widespread
but weaker 262.898 GHz water line in v$_2$ = 1 also shows signs of maser
emission. Emission and absorption of both H$_2$O and OH reveal an infall of
matter and complex kinematics influenced by binarity. From our observed column
densities, we derived OH/H$_2$O abundance ratios in a few stars.
