Since the probability of selecting student 1's number is 1/8 and then replacing it leaves us with still 8 numbers to choose from, so student 8's probability of being selected is also 1/8. Multiplying these two gives P=1/64, since (1/8)^2 = 1/64.
First draw the box with the diagonal, as you can see it is split into 2 equal right triangles. Now use the pythagorean theorem (a^2+b^2=c^2) to find the length of the diagonal