Test cases for UnionFind