Function to find Union
def Union ( a , b ) : NEW_LINE INDENT i = Root ( a ) NEW_LINE j = Root ( b ) ; NEW_LINE if ( i != j ) : NEW_LINE INDENT if ( sz [ i ] >= sz [ j ] ) : NEW_LINE INDENT id [ j ] = i NEW_LINE sz [ i ] += sz [ j ] ; NEW_LINE sz [ j ] = 0 ; NEW_LINE DEDENT else : NEW_LINE INDENT id [ i ] = j NEW_LINE sz [ j ] += sz [ i ] ; NEW_LINE sz [ i ] = 0 ; NEW_LINE DEDENT DEDENT DEDENT