import sequtils,algorithm,strutils,intsets,tables,sugar 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 let n = scan() let m = scan() let k = scan() let ABC = newSeqWith(m,(a:scan(),b:scan(),c:scan())) var oks = newSeqWith(n+1,true) k.times: var nexts = newSeqWith(n+1,false) let d = scan() for i in 0..