Vector a , b , c are used to store the final output
vector < int > a ; vector < int > b ; vector < int > c ; int ans ; int dfs ( int w ) { if ( cd [ w ] == 0 ) return w ; if ( wt [ w ] < ans ) ans = wt [ w ] ; return dfs ( cd [ w ] ) ; }