import macros macro Please(x): untyped = nnkStmtList.newTree() Please use Nim-ACL Please use Nim-ACL Please use Nim-ACL import macros;macro ImportExpand(s:untyped):untyped = parseStmt($s[2]) import macros # {.checks: off.} ImportExpand "cplib/tmpl/citrus.nim" <=== "when not declared CPLIB_TMPL_CITRUS:\n const CPLIB_TMPL_CITRUS* = 1\n {.warning[UnusedImport]: off.}\n {.hint[XDeclaredButNotUsed]: off.}\n import os\n import algorithm\n import sequtils\n import tables\n import macros\n import std/math\n import sets\n import strutils\n import strformat\n import sugar\n import streams\n import deques\n import bitops\n import heapqueue\n const MODINT998244353* = 998244353\n const MODINT1000000007* = 1000000007\n const INF* = 100100111\n const INFL* = int(3300300300300300491)\n type double* = float64\n let readNext = iterator(getsChar: bool = false): string {.closure.} =\n while true:\n var si: string\n try: si = stdin.readLine\n except EOFError: yield \"\"\n for s in si.split:\n if getsChar:\n for i in 0..>`*(x: int, y: int): int = x shr y\n proc `<<`*(x: int, y: int): int = x shl y\n proc `%=`*(x: var SomeInteger or int64, y: SomeInteger or\n int64): void = x = x % y\n proc `//=`*(x: var int, y: int): void = x = x // y\n proc `^=`*(x: var int, y: int): void = x = x ^ y\n proc `&=`*(x: var int, y: int): void = x = x & y\n proc `|=`*(x: var int, y: int): void = x = x | y\n proc `>>=`*(x: var int, y: int): void = x = x >> y\n proc `<<=`*(x: var int, y: int): void = x = x << y\n proc `[]`*(x: int, n: int): bool = (x and (1 shl n)) != 0\n\n proc pow*(a, n: int, m = INFL): int =\n var\n rev = 1\n a = a\n n = n\n while n > 0:\n if n % 2 != 0: rev = (rev * a) mod m\n if n > 1: a = (a * a) mod m\n n >>= 1\n return rev\n proc sqrt*(x: int): int =\n assert(x >= 0)\n result = int(sqrt(float64(x)))\n while result * result > x: result -= 1\n while (result+1) * (result+1) <= x: result += 1\n proc chmax*[T](x: var T, y: T): bool = (if x < y: (x = y; return true;\n ) return false)\n proc chmin*[T](x: var T, y: T): bool = (if x > y: (x = y; return true;\n ) return false)\n proc `max=`*[T](x: var T, y: T) = x = max(x, y)\n proc `min=`*[T](x: var T, y: T) = x = min(x, y)\n proc at*(x: char, a = '0'): int = int(x) - int(a)\n converter tofloat*(n: int): float = float(n)\n iterator rangeiter*(start: int, ends: int, step: int): int =\n var i = start\n if step < 0:\n while i > ends:\n yield i\n i += step\n elif step > 0:\n while i < ends:\n yield i\n i += step\n iterator rangeiter*(ends: int): int = (for i in 0.. costs[i]:\n continue\n for (j, c) in G.edges[i]:\n var temp = costs[i] + c\n if temp < costs[j]:\n prev[j] = i\n costs[j] = temp\n queue.push((temp, j))\n return (costs, prev)\n proc dijkstra*[T](G: Graph[T], start: int, ZERO: T = 0, INF: T = int(3300300300300300491)): seq[T] =\n var costs, _ = restore_dijkstra(G, start, ZERO, INF)\n return costs\n proc restore_shortestpath_from_prev*(prev: seq[int], goal: int): seq[int] =\n var i = goal\n while i != -1:\n result.add(i)\n i = prev[i]\n result = result.reversed()\n proc shortest_path*[T](G: Graph[T], start: int, goal: int, ZERO: T = 0, INF: T = int(3300300300300300491)): tuple[path: seq[int], cost: int] =\n var (costs, prev) = restore_dijkstra(G, start, ZERO, INF)\n result.path = prev.restore_shortestpath_from_prev(goal)\n result.cost = costs[goal]\n discard\n" var n,m = input(int) var g = initweighteddirectedgraph(n,int) var gi = initweighteddirectedgraph(n,int) for i in 0..= inf: print(-1) else: print(ans)