List a , b , c are used to store the final output
a = [ ] NEW_LINE b = [ ] NEW_LINE c = [ ] NEW_LINE ans = 0 NEW_LINE def dfs ( w ) : NEW_LINE INDENT global ans NEW_LINE if ( cd [ w ] == 0 ) : NEW_LINE INDENT return w NEW_LINE DEDENT if ( wt [ w ] < ans ) : NEW_LINE INDENT ans = wt [ w ] NEW_LINE DEDENT return dfs ( cd [ w ] ) NEW_LINE DEDENT