I want to calculate the word associated with the connected sum of two surfaces with boundary but I don't know how to proceed. I know that the word associated with the connected sum of two surfaces without boundary $X_1$ (with word $p_1$) and $X_2$ (with word $p_2$) is just $p_1p_2$.
At first I didn't even know how to make the connected sum of two surfaces with boundary but after reading this question that became clearer.
I also know the theorem of classification for surfaces with boundary but I don't know how to connect all this to calculate the resulting word.
How should I proceed? I don't know how to adapt the theorem for surfaces without boundary because of the special form of the neighbourhoods of the boundary points. Any hint would be greatly appreciated.