If a pipe has no ending vertex but has starting vertex i . e is an outgoing pipe then we need to start DFS with this vertex .
if ( rd [ j ] == 0 && cd [ j ] > 0 ) { ans = 1000000000 ; let w = dfs ( j ) ;