Edges in MST (Codeforces 160D problem)

I am unable to understand the solution of this question.

Question link : Problem - 160D - Codeforces

Solution link : Submission #35835930 - Codeforces

I basically want to the intuitive approach behind this. I have given this solution link because it has been submitted by most of the users.

If there is any other approach or solution other than this, Please explain that one as I just want to know approach so that I can code.

Thanks :grinning: