union(int p, int q) algorithm chaged