The numeratorleft hand factor counts the number of outcomes where $Y$ exceeds $X$ while the right hand factor of $1/(nm)$ converts that to a probability. (The count can be simplified to $m(2n-m-1)/2$$m(2n-m-1)$ for computational purposes, but thisthat simpler formula hidesobscures the idea that led to the answer. In)
In case $m$ is the larger number, the sum stops with $n-m=0$ giving a simpler value: