We give combinatorial descriptions of the Heegaard Floer homology groups for
arbitrary three-manifolds (with coefficients in Z/2). The descriptions are
based on presenting the three-manifold as an integer surgery on a link in the
three-sphere, and then using a grid diagram for the link. We also give
combinatorial descriptions of the mod 2 Ozsvath-Szabo mixed invariants of
closed four-manifolds, in terms of grid diagrams.