
from __future__ import annotations






def  a_	( __lowercase     :			Tuple ,      __lowercase     :			int ,      __lowercase     :			int				)				->						int:
   assert n > 1 and a > 0 and greatest_common_divisor(__lowercase ,      __lowercase				) == 1
   (_snake_case)						=    extended_gcd(__lowercase ,      __lowercase				)  # Implemented below
   _snake_case						=    (b * s) % n
   return x






def  a_	( __lowercase     :			str ,      __lowercase     :			str				)				->						int:
   (_snake_case)						=    extended_euclid(__lowercase ,      __lowercase				)  # Implemented below
   if b < 0:
      _snake_case						=    (b % n + n) % n
   return b






def  a_	( __lowercase     :			Union[str, Any] ,      __lowercase     :			int ,      __lowercase     :			Union[str, Any]				)				->						int:
   _snake_case						=    invert_modulo(__lowercase ,      __lowercase				)
   _snake_case						=    (b * s) % n
   return x






def  a_	( __lowercase     :			Any ,      __lowercase     :			Optional[Any]				)				->						tuple[int, int, int]:
   assert a >= 0 and b >= 0

   if b == 0:
      _snake_case						=    a, 1, 0
   else:
      (_snake_case)						=    extended_gcd(__lowercase ,      a % b				)
      _snake_case						=    q
      _snake_case						=    p - q * (a // b)

   assert a % d == 0 and b % d == 0
   assert d == a * x + b * y

   return (d, x, y)






def  a_	( __lowercase     :			str ,      __lowercase     :			Optional[Any]				)				->						tuple[int, int]:

   if b == 0:
      return (1, 0)
   (_snake_case)						=    extended_euclid(__lowercase ,      a % b				)
   _snake_case						=    a // b
   return (y, x - k * y)






def  a_	( __lowercase     :			Optional[int] ,      __lowercase     :			Union[str, Any]				)				->						int:

   if a < b:
      _snake_case						=    b, a

   while a % b != 0:
      _snake_case						=    b, a % b

   return b


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

   testmod(name='''modular_division''', verbose=True)
   testmod(name='''modular_division2''', verbose=True)
   testmod(name='''invert_modulo''', verbose=True)
   testmod(name='''extended_gcd''', verbose=True)
   testmod(name='''extended_euclid''', verbose=True)
   testmod(name='''greatest_common_divisor''', verbose=True)

_lowerCamelCase :       Union[str, Any]     					=    {
    0: '''underwear''',
    1: '''pants''',
    2: '''belt''',
    3: '''suit''',
    4: '''shoe''',
    5: '''socks''',
    6: '''shirt''',
    7: '''tie''',
    8: '''watch''',
}

_lowerCamelCase :       Optional[Any]     					=    [[1, 4], [2, 4], [3], [], [], [4], [2, 7], [3], []]

_lowerCamelCase :       Dict     					=    [0 for x in range(len(graph))]
_lowerCamelCase :       Dict     					=    []






def  a_	( __lowercase     :			Optional[int] ,      __lowercase     :			Dict				)				->						Optional[int]:
			_snake_case						=    1
			while stack:
						_snake_case						=    stack.pop()
						print(__lowercase ,      clothes[current_clothing]				)
						order += 1






def  a_	( __lowercase     :			Union[str, Any] ,      __lowercase     :			Dict ,      __lowercase     :			Union[str, Any]				)				->						List[Any]:
			_snake_case						=    1
			for v in graph[u]:
						if not visited[v]:
									depth_first_search(__lowercase ,      __lowercase ,      __lowercase				)

			stack.append(__lowercase				)






def  a_	( __lowercase     :			Dict ,      __lowercase     :			int				)				->						List[str]:
			for v in range(len(__lowercase				)				):
						if not visited[v]:
									depth_first_search(__lowercase ,      __lowercase ,      __lowercase				)


if __name__ == "__main__":
			topological_sort(graph, visited)
			print(stack)
			print_stack(stack, clothes)