def smallestRange(nums: List[List[int]]) -> List[int]:
heap = [(arr[0], i, 0) for i, arr in enumerate(nums)]
heapq.heapify(heap)
right = max(arr[0] for arr in nums)
ans = (-math.inf, math.inf)
while heap:
left, row, col = heapq.heappop(heap)
if right - left < ans[1] - ans[0]:
ans = left, right
if col + 1 == len(nums[row]):
return ans
next_point = nums[row][col + 1]
right = max(right, next_point)
heapq.heappush(heap, (next_point, row, col + 1))