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.
The basic idea is that:
For instance, when you remove a disc from the torus $aba^{-1}b^{-1}$, you get a surface with symbol $aba^{-1}b^{-1}c$. (Of course, the process is more complicated. You need to add the new symbol at the location where it is not adjacent to the another boundary; otherwise the two will just collapse into one. In case there is no more place to add, you might need to break up an existing symbol.)
Now back to your problem, for a surface with word $p_1$, taking a disk out, you get a surface with symbol $p_1 c$. Likewise, for surface $p_2$, you get $c p_2$. Now you identified the two disk $c$ together; the quotient topology construction dictates that the resulting surface has the word $p_1 p_2$. (I can draw a picture later if you need.)