Help need in "Two types of queries" from hackerearth .link in discription

Two types of queries | Practice Problems

i have used find and union functions of disjoint sets to solve the problem . TO avoid tle i have also used the fact that if there are more than 25 queries of type 1(different) then the answer would be zero . But it is giving wa .
help please