import sys;input=sys.stdin.readline from heapq import * def dijkstra_heapq(s, cost): d = [float("inf")] * N h = [(0, s)] d[s] = 0 while h: vc, v = heappop(h) # print(h) if vc > d[v]: continue for j, c in cost[v]: if vc+c