UnionFind and Segment tree