import sequtils,math template times*(n:int,body) = (for _ in 0.." ,discardable.} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': return result = 10 * result + k.ord - '0'.ord template useUnionFind() = # 同一集合の判定/マージ が 実質 O(1) type UnionFind[T] = ref object parent : seq[T] proc newUnionFind[T](size:int) : UnionFind[T] = new(result) result.parent = newSeqUninitialized[T](size) for i in 0.int32..