





import heapq as hq
import math
from collections.abc import Iterator





class UpperCAmelCase_				:


  def __init__(							self ,__snake_case ):



       """simple docstring"""





       A_          =       str(id_ )
       A_          =       None
       A_          =       None
       A_          =       []
       A_          =       {}  # {vertex:distance}


  def __lt__(							self ,__snake_case ):



       """simple docstring"""





       return self.key < other.key


  def __repr__(							self ):



       """simple docstring"""





       return self.id


  def 						__UpperCAmelCase     (							self ,__snake_case ):



       """simple docstring"""





       self.neighbors.append(__snake_case )




  def 						__UpperCAmelCase     (							self ,__snake_case ,__snake_case ):



       """simple docstring"""





       A_          =       weight




def      UpperCAmelCase_    (    _UpperCAmelCase							:Optional[int]  ,						_UpperCAmelCase							:List[str]  ,						_UpperCAmelCase							:Optional[Any]  ,						_UpperCAmelCase							:List[str]				)	->				Optional[Any]:
     '''simple docstring'''


     graph[a - 1].add_neighbor(graph[b - 1]				)
     graph[b - 1].add_neighbor(graph[a - 1]				)
     # add the edges:
     graph[a - 1].add_edge(graph[b - 1]  ,						_UpperCAmelCase				)
     graph[b - 1].add_edge(graph[a - 1]  ,						_UpperCAmelCase				)

def      UpperCAmelCase_    (    _UpperCAmelCase							:list  ,						_UpperCAmelCase							:Vertex				)	->				list:
     '''simple docstring'''


     A_          =       []
     for u in graph:
          A_          =       math.inf
          A_          =       None
     A_          =       0
     A_          =       graph[:]
     while q:
          A_          =       min(_UpperCAmelCase				)
          q.remove(_UpperCAmelCase				)
          for v in u.neighbors:
               if (v in q) and (u.edges[v.id] < v.key):
                    A_          =       u
                    A_          =       u.edges[v.id]
     for i in range(1  ,						len(_UpperCAmelCase				)				):
          a.append((int(graph[i].id				) + 1, int(graph[i].pi.id				) + 1)				)
     return a

def      UpperCAmelCase_    (    _UpperCAmelCase							:list  ,						_UpperCAmelCase							:Vertex				)	->				Iterator[tuple]:
     '''simple docstring'''


     for u in graph:
          A_          =       math.inf
          A_          =       None
     A_          =       0

     A_          =       list(_UpperCAmelCase				)
     hq.heapify(_UpperCAmelCase				)

     while h:
          A_          =       hq.heappop(_UpperCAmelCase				)
          for v in u.neighbors:
               if (v in h) and (u.edges[v.id] < v.key):
                    A_          =       u
                    A_          =       u.edges[v.id]
                    hq.heapify(_UpperCAmelCase				)

     for i in range(1  ,						len(_UpperCAmelCase				)				):
          yield (int(graph[i].id				) + 1, int(graph[i].pi.id				) + 1)

def      UpperCAmelCase_    (    )	->				None:
     '''simple docstring'''




if __name__ == "__main__":
      import doctest

      doctest.testmod()










import requests

a__      :     Any         =		'YOUR API KEY'

def      UpperCAmelCase_    (    _UpperCAmelCase							:str  ,						_UpperCAmelCase							:str = giphy_api_key				)	->				list:
     '''simple docstring'''


     A_          =       '''+'''.join(query.split()				)
     A_          =       f'https://api.giphy.com/v1/gifs/search?q={formatted_query}&api_key={api_key}'
     A_          =       requests.get(_UpperCAmelCase				).json()['''data''']
     return [gif["url"] for gif in gifs]


if __name__ == "__main__":
      print('\n'.join(get_gifs('space ship')))



