





'''simple docstring'''




from __future__ import annotations






def 	_lowerCAmelCase      (  __snake_case  :			list			,							__snake_case  :			int | None = None			,							__snake_case  :			int | None = None      )					->					Tuple:
     if start is None:
          __A						:			int								=	0

     if end is None:
          __A						:			Any								=	len(__snake_case      ) - 1

     if start >= end:
          return

     __A						:			Dict								=	(start + end) // 2

     slowsort(__snake_case			,							__snake_case			,							__snake_case      )
     slowsort(__snake_case			,							mid + 1			,							__snake_case      )

     if sequence[end] < sequence[mid]:
          __A						:			str								=	sequence[mid], sequence[end]

     slowsort(__snake_case			,							__snake_case			,							end - 1      )


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

  testmod()






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