#yuki94 import sys class Unionfind: def __init__(self,N): self.par=[-1]*N def root(self,x): if self.par[x]<0: return x self.par[x]=self.root(self.par[x]) return self.par[x] def find(self,x,y): return self.root(x)==self.root(y) def unite(self,x,y): rx,ry=self.root(x),self.root(y) if rx!=ry: rx_num,ry_num=-self.par[rx],-self.par[ry] if rx_num>ry_num or (rx_num==ry_num and rxrx_num or (rx_num==ry_num and ry