Use UnionFind library at ARC027 B