The task is to make data structure with the following operations:
query: takes two arguments s and t and returns true if they are in the same set and false otherwise.
union: takes two arguments s and t and creates a union of the two sets that contain s and t such that if s is in S and t is in T it removes S and T and replaces it with the union of S and T.
move: takes two arguments s and t and takes s out of its current set and moves s and only s to the set containing t.
union and move don't do anything if s and t are in the same set.
My question is: how do you make an efficient version of this data structure that is < O(n²)?