Function to find the root of ith node in the disjoint set
def root ( arr : list , i : int ) -> int : NEW_LINE INDENT while arr [ i ] != i : NEW_LINE INDENT i = arr [ i ] NEW_LINE DEDENT return i NEW_LINE DEDENT