import strutils, sequtils, math, sets const MOD = 10 ^ 9 + 7 var graph: seq[seq[int]] r: HashSet[int] dp: array[1000010, int] depth: array[1000010, int] proc solve() = let N = stdin.readLine.parseInt graph = newSeqWith(N, newSeq[int]()) r = initHashSet[int]() for i in 0..