How to Pair Generators in the Presentation of Fundamental Group of a Surface The fundamental group of a surface with genus $g$ is widely given by the group presentation (for example Hatcher p.51):
$$\langle  a(1),b(1),a(2),b(2),..,a(g),b(g) \mid  [a(1),b(1)][a(2),b(2)]...[a(g),b(g)] \rangle$$
However, as stated, the fundamental group appears to be imperfectly defined in the general case.  Specifically, the $a$-$b$ pairing is not defined.  Given the generators, one cannot use the formula without knowing how to pair them.
In other words, suppose I know the generators of a complex surface, which I arbitrarily label as $1,2,3,...,2g $.   I still cannot get the fundamental group without knowing which generators are to be paired to construct the relation.
For genus $g$ surfaces, what is the algorithm/logic for pairing the generators in the presentation of the fundamental group?
 A: On page 51 of Hatcher, it is assumed that we start with an orientable surface $M_g$ of genus $g$ and have its cell structure. The cell structure contains the information of not only the cells, but how they fit together - this data is contained in the gluing maps. Since the 1-skeleton is a wedge sum of $2g$ circles, almost all of the information is included in the map gluing the 2-cell to the 1-skeleton. In particular, the boundary of the 2-cell is divided into $4g$ arcs that are identified in pairs. Each (oriented) pair is a generator of the fundamental group (by identifying it with the 1-cell it glues to) and the gluing order is the commutator relation. If you draw a square for the torus and an octagon for a genus 2 surface and work out the details, then you will see that the cell complex structure dictates the fundamental group presentation up to rotations of the 2-cell (treating it like a disc) by integral multiples of $\frac{2\pi}{4g}$ and possibly a reflection (i.e. a dihedral group).
How the pairing is in the gluing maps Given a arc $A_1$ of the 2-cell $D$, the gluing map $G$ identifies the arc with a 1-cell $I$. On the other hand, there is another arc $A_2$ of the 2-cell that is also identified with $I$ via $G$. This is because we are by hypothesis working with the cell complex structure of a orientable surface. Our hypothesis doesn't include the specifics of which cell complex we are working with beyond that, and as such we have no more information. In the concrete situation of working with an actual cell complex of an orientable surface then you can look at the map $G$ and see where it sends the boundary of $D$.
