The Ernst equation is formulated on an arbitrary Riemann surface. Anal
ytically, the problem reduces to finding solutions of the ordinary Ern
st equation which are periodic along the symmetry axis. The family of
(punctured) Riemann surfaces admitting a non-trivial Ernst field const
itutes a ''partially discretized'' subspace of the usual moduli space.
The method allows us to construct new exact solutions of Einstein's e
quations in vacuo with non-trivial topology, such that different ''uni
verses'', each of which may have several black holes on its symmetry a
xis, are connected through necks bounded by cosmic strings. We show ho
w the extra topological degrees of freedom may lead to an extension of
the Geroch group and discuss possible applications to string theory.