using quick-union and find