import sequtils, strutils, strformat, algorithm, math, sugar, hashes, tables const (INF*, AZ*) = (10^18+9, 26) import complex, random, deques, heapqueue, sets, macros var inFile = stdin let inps* = iterator: string {.closure.} = (while true: (for s in inFile.readLine.split: yield s)) let (inp*, inpf*) = (() => parseInt(inps()), () => parseFloat(inps())) func chmax*[T](t: var T; v: T): bool{.discardable.} = (let f = (t < v); if f: t = v; f) func chmin*[T](t: var T; v: T): bool{.discardable.} = (let f = (t > v); if f: t = v; f) func inRange*[T](L, v, r: T): bool = (L < r) and ((L <= v) and (v < r)) func inRange*(x, y, w, h: int): bool = inRange(0, y, h) and inRange(0, x, w) func sqrt*(v: int): int = toInt(trunc(sqrt(toFloat(v)))) template if3*(cond: bool; t, f: untyped): auto = (if cond: t else: f) func divCeil*(a, b: int): int = (a+b-1) div b template echoQuit*(ans: typed) = (echo(ans); quit(0)) template newSeqWith*(y, x: int; p: untyped): untyped = newSeqWith(y, newSeqWith(x, p)) func hash*(x: int): Hash = x*7 func char2int*(c, def: char): int = ord(c)-ord(def) func inc*[T](ct: var Table[T, int]; k: T; v = 1) = (ct[k] = ct.getOrDefault(k) + v) func dec*[T](ct: var Table[T, int]; k: T; v = 1) = (if ct.hasKey(k): (if ct[k] <= v: ct.del(k) else: ct[k] -= v)) func nibutan*(ok, ng: int; isOK: (int)->bool): int = (var (ok, ng) = (ok, ng); (while (abs(ok - ng) > 1): (let mid = (ng + ok) div 2; if isOk(mid): ok = mid else: ng = mid)); return ok) proc echo*(f: float) = echo(fmt"{f:.20f}") func cmod*[T](n, md: T): T = (n mod md + md) mod md template addEdges*(g: seq[seq]; n: int; frm, to: untyped) = (for i in 0..n: g[frm].add(to)) when defined(debug): #デバッグ時だけ使える命令など template eprintf*(x: typed) = echo("[debug] --- ", x) else: template eprintf*(x: typed) = discard macro dump*(x: typed): untyped = discard {.warning[UnusedImport]: off.} #----- ここまでテンプレ ----- let N = inp() var G = newSeqWith(N, 0, 0) for i in 0..