input: from typing import List
  from heapq import heappop, heappush
  
  def minimum_time(n: int, edges: List[List[int]], disappear: List[int]) -> List[int]:
      """
      There is an undirected graph of n nodes. You are given a 2D array edges, where edges[i] = [ui, vi, lengthi] describes an edge between node ui and node vi with a traversal time of lengthi units.
  
      Additionally, you are given an array disappear, where disappear[i] denotes the time when the node i disappears from the graph and you won't be able to visit it.
  
      Notice that the graph might be disconnected and might contain multiple edges.
  
      Return the array answer, with answer[i] denoting the minimum units of time required to reach node i from node 0. If node i is unreachable from node 0 then answer[i] is -1.
  
      Examples:
      >>> minimum_time(3, [[0,1,2],[1,2,1],[0,2,4]], [1,1,5])
      [0,-1,4]
      >>> minimum_time(3, [[0,1,2],[1,2,1],[0,2,4]], [1,3,5])
      [0,2,3]
      >>> minimum_time(2, [[0,1,1]], [1,1])
      [0,-1]
  
      Constraints:
      1 <= n <= 5 * 10^4
      0 <= edges.length <= 10^5
      edges[i] == [ui, vi, lengthi]
      0 <= ui, vi <= n - 1
      1 <= lengthi <= 10^5
      disappear.length == n
      1 <= disappear[i] <= 10^5
      """
  
output: 
      graph = [[] for _ in range(n)]
      for u, v, length in edges:
          graph[u].append((v, length))
          graph[v].append((u, length))
  
      min_time = [float('inf')] * n
      min_time[0] = 0
      pq = [(0, 0)]
  
      while pq:
          current_time, node = heappop(pq)
          if current_time > disappear[node]:
              continue
          for neighbor, length in graph[node]:
              new_time = current_time + length
              if new_time < min_time[neighbor] and new_time <= disappear[neighbor]:
                  min_time[neighbor] = new_time
                  heappush(pq, (new_time, neighbor))
  
      for i in range(n):
          if min_time[i] == float('inf'):
              min_time[i] = -1
  
      return min_time
  