





"""simple docstring"""




from __future__ import annotations

from queue import Queue




class 					_a		:






				def __init__(					self						:       Union[str, Any]				)      -> None:




										'''simple docstring'''



										_UpperCamelCase     :   dict[int, list[int]]      =       {}






				def 							snake_case      (					self						:       Optional[Any]				)      -> None:




										'''simple docstring'''



										for i in self.vertices:
																print(lowerCAmelCase__,					''' : ''',					''' -> '''.join([str(lowerCAmelCase__				) for j in self.vertices[i]]				)				)






				def 							snake_case      (					self						:       Optional[int],					lowerCAmelCase__						:       int,					lowerCAmelCase__						:       int				)      -> None:




										'''simple docstring'''



										if from_vertex in self.vertices:
																self.vertices[from_vertex].append(lowerCAmelCase__				)
										else:
																_UpperCamelCase     :   List[Any]      =       [to_vertex]






				def 							snake_case      (					self						:       int,					lowerCAmelCase__						:       int				)      -> set[int]:




										'''simple docstring'''



										_UpperCamelCase     :   Dict      =       set()

										# create a first in first out queue to store all the vertices for BFS
										_UpperCamelCase     :   Queue      =       Queue()

										# mark the source node as visited and enqueue it
										visited.add(lowerCAmelCase__				)
										queue.put(lowerCAmelCase__				)

										while not queue.empty():
																_UpperCamelCase     :   Optional[int]      =       queue.get()

																# loop through all adjacent vertex and enqueue it if not yet visited
																for adjacent_vertex in self.vertices[vertex]:
																						if adjacent_vertex not in visited:
																												queue.put(lowerCAmelCase__				)
																												visited.add(lowerCAmelCase__				)
										return visited


if __name__ == "__main__":
						from doctest import testmod

						testmod(verbose=True)

						UpperCamelCase_	 =Graph()
						g.add_edge(0, 1)
						g.add_edge(0, 2)
						g.add_edge(1, 2)
						g.add_edge(2, 0)
						g.add_edge(2, 3)
						g.add_edge(3, 3)

						g.print_graph()
						# 0  :  1 -> 2
						# 1  :  2
						# 2  :  0 -> 3
						# 3  :  3

						assert sorted(g.bfs(2)) == [0, 1, 2, 3]










from functools import lru_cache







@lru_cache
def      A__				(       SCREAMING_SNAKE_CASE__)  ->       int:
  if not isinstance(SCREAMING_SNAKE_CASE__   ,   SCREAMING_SNAKE_CASE__):
    raise TypeError("""k must be an integer.""")
  if k < 0:
    raise ValueError("""k integer must be greater or equal to zero.""")
  if k == 0:
    return 0
  elif k == 1:
    return 1
  else:
    return fibonacci(k - 1) + fibonacci(k - 2)







def      A__				(       SCREAMING_SNAKE_CASE__   ,   SCREAMING_SNAKE_CASE__)  ->       int:
  __snake_case:		str					    =		len(SCREAMING_SNAKE_CASE__)
  # Find m such that F_m >= n where F_i is the i_th fibonacci number.
  __snake_case:		Optional[int]					    =		0
  while True:
    if fibonacci(SCREAMING_SNAKE_CASE__) >= len_list:
      __snake_case:		str					    =		i
      break
    i += 1
  __snake_case:		Tuple					    =		0
  while fibb_k > 0:
    __snake_case:		str					    =		min(
        offset + fibonacci(fibb_k - 1)   ,   len_list - 1)  # Prevent out of range
    __snake_case:		List[Any]					    =		arr[index_k]
    if item_k_1 == val:
      return index_k
    elif val < item_k_1:
      fibb_k -= 1
    elif val > item_k_1:
      offset += fibonacci(fibb_k - 1)
      fibb_k -= 2
  else:
    return -1


if __name__ == "__main__":
      import doctest

      doctest.testmod()






