classUF: def __init__(self, N): self.id = list(range(N)) self.sz = list(1 fori in range(N)) self.count = N def GetCount(self): returnself.count def find(self,p): whilep!=self.id[p]: self.id[p] = self.id[self.i...