dynamic connectivity(union find) - eager approach