UnionFind exercises (first lesson)