Add code for Union-Find