The goal of this science case is to study physical conditions of the interstellar medium (ISM) in distant galaxies. In particular, its densest component is associated with the inner cores of clouds -- this is where star formation takes place. Carbon monoxide is usually used to trace molecular gas emission; however, its transitions are practically opaque, thus preventing astronomers from piercing through the clouds, into the deepest layers that are most intimately connected with the formation of stars. Other dense gas tracers are required, although they are typically too faint and/or at too low frequencies to be effectively observed in high redshift galaxies. The ngVLA will offer for the first time the sensitivity at radio frequencies that is needed to target [CI]$_{1-0}$ (at $z>5$), as well as the ground transitions of dense gas tracers of the ISM such as HCN, HNC, HCO+ (at various redshifts $z>1$), beyond the tip of the iceberg of the hyper-luminous sources that could be studied up to now. These new tools will critically contribute to our understanding of the intimate interplay between gas clouds and star formation in different environments and cosmic epochs.