Solution (source code)

= Solution

$P$ is a square with two open square holes; its boundary is the three square boundary curves. Using their twelve corners gives a triangulation with $V=12,E=27,F=14$. Doubling two compact connected copies along their common boundary is compact and connected, and boundary half-discs glue to discs, so the double is locally Euclidean and is a closed surface. Under the quotient the doubled triangulation has $V=12,E=42,F=28$, hence $\chi=-2$. The classification theorem says a connected compact orientable surface is a sphere or a connected sum of $k$ tori with $\chi=2-2k$; thus $k=2$.