





'''simple docstring'''




import enum
import shutil
import sys


lowercase__     ,							lowercase__   :				Any      =   shutil.get_terminal_size()

lowercase__   :				Union[str, Any]      =   {'''UP''': '''A''', '''DOWN''': '''B''', '''RIGHT''': '''C''', '''LEFT''': '''D'''}


class 			SCREAMING_SNAKE_CASE   (enum.Enum							):
     lowerCAmelCase		      =	0
     lowerCAmelCase		      =	1






def 	_lowerCAmelCase      (  __snake_case  :			Optional[int]			,							__snake_case  :			str=""      )					->					Optional[Any]:
     sys.stdout.write(str(__snake_case      ) + end      )
     sys.stdout.flush()






def 	_lowerCAmelCase      (  __snake_case  :			Optional[int]			,							__snake_case  :			Dict			,							__snake_case  :			Union[str, Any]=""      )					->					List[str]:
     forceWrite(f'\u001b[{color}m{content}\u001b[0m'			,							__snake_case      )






def 	_lowerCAmelCase      (  )					->					Any:
     forceWrite('\r'      )






def 	_lowerCAmelCase      (  __snake_case  :			int			,							__snake_case  :			str      )					->					Optional[Any]:
     forceWrite(f'\033[{num_lines}{CURSOR_TO_CHAR[direction.upper()]}'      )






def 	_lowerCAmelCase      (  )					->					Optional[Any]:
     forceWrite(' ' * TERMINAL_WIDTH      )
     reset_cursor()







def 	_lowerCAmelCase      (  )					->					Any:
     reset_cursor()
     forceWrite('-' * TERMINAL_WIDTH      )






'''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)