import sequtils template times*(n:int,body) = (for _ in 0.." .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord template useUnionFind = type UnionFind[T] = object parent : seq[T] proc root[T](self:var UnionFind[T],x:T): T = if self.parent[x] == x: return x self.parent[x] = self.root(self.parent[x]) return self.parent[x] proc initUnionFind[T](size:int) : UnionFind[T] = result.parent = newSeqUninitialized[T](size) for i in 0.int32.. 2 : quit "NO",0 roots &= uf.root(v) if roots.allIt(it == roots[0]): echo "YES" else: echo "NO"