help in a probability question.

prob link : Problem - 698C - Codeforces

can someone please explain me the solution of this. I have read comments(as editorial is not available) but didn’t understand the idea. please help!

Thanks!

guys if possible please look into it.