





'''simple docstring'''




import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
  import ctypes
  import msvcrt  # noqa


  class 			SCREAMING_SNAKE_CASE   (ctypes.Structure							):
       # _fields is a specific attr expected by ctypes
       lowerCAmelCase		      =	[('''size''', ctypes.c_int), ('''visible''', ctypes.c_byte)]






def 	_lowerCAmelCase      (  )					->					Any:

     if os.name == "nt":
          __A						:			str								=	CursorInfo()
          __A						:			Optional[Any]								=	ctypes.windll.kernelaa.GetStdHandle(-11      )
          ctypes.windll.kernelaa.GetConsoleCursorInfo(_lowerCamelCase			,							ctypes.byref(_lowerCamelCase      )      )
          __A						:			Optional[Any]								=	False
          ctypes.windll.kernelaa.SetConsoleCursorInfo(_lowerCamelCase			,							ctypes.byref(_lowerCamelCase      )      )
     elif os.name == "posix":
          sys.stdout.write('\033[?25l'      )
          sys.stdout.flush()






def 	_lowerCAmelCase      (  )					->					Union[str, Any]:

     if os.name == "nt":
          __A						:			Optional[Any]								=	CursorInfo()
          __A						:			Optional[int]								=	ctypes.windll.kernelaa.GetStdHandle(-11      )
          ctypes.windll.kernelaa.GetConsoleCursorInfo(_lowerCamelCase			,							ctypes.byref(_lowerCamelCase      )      )
          __A						:			Optional[int]								=	True
          ctypes.windll.kernelaa.SetConsoleCursorInfo(_lowerCamelCase			,							ctypes.byref(_lowerCamelCase      )      )
     elif os.name == "posix":
          sys.stdout.write('\033[?25h'      )
          sys.stdout.flush()







@contextmanager
def 	_lowerCAmelCase      (  )					->					List[str]:

     try:
          hide_cursor()
          yield
     finally:
          show_cursor()






'''simple docstring'''




def 	_lowerCAmelCase      (  __snake_case  :			str      )					->					str:
     __A						:			Optional[Any]								=	[0] * len(__snake_case      )
     __A						:			Dict								=	[]
     __A						:			Optional[int]								=	[1] * len(__snake_case      )

     for values in graph.values():
          for i in values:
               indegree[i] += 1

     for i in range(len(__snake_case      )      ):
          if indegree[i] == 0:
               queue.append(__snake_case      )

     while queue:
          __A						:			int								=	queue.pop(0      )
          for x in graph[vertex]:
               indegree[x] -= 1

               if long_dist[vertex] + 1 > long_dist[x]:
                    __A						:			str								=	long_dist[vertex] + 1

               if indegree[x] == 0:
                    queue.append(__snake_case      )

     print(max(__snake_case      )      )


# Adjacency list of Graph
lowercase__   :				Dict      =   {0: [2, 3, 4], 1: [2, 7], 2: [5], 3: [5, 7], 4: [7], 5: [6], 6: [7], 7: []}







longest_distance(graph)