Minimum spanning tree for each edge

CodeForces - 609E