

class 				__lowerCAmelCase  :




  def __init__(       self							,     lowerCAmelCase      )						->				Tuple:
        '''simple docstring'''






        _lowercase			 =n
        _lowercase			 =[None] * self.n
        _lowercase			 =0  # index of the first element
        _lowercase			 =0
        _lowercase			 =0




  def __len__(       self      )						->				int:
        '''simple docstring'''






        return self.size




  def 						A__  (       self      )						->				bool:
        '''simple docstring'''






        return self.size == 0




  def 						A__  (       self      )						->				List[str]:
        '''simple docstring'''






        return False if self.is_empty() else self.array[self.front]




  def 						A__  (       self							,     lowerCAmelCase      )						->				List[Any]:
        '''simple docstring'''






        if self.size >= self.n:
              raise Exception('QUEUE IS FULL'      )

        _lowercase			 =data
        _lowercase			 =(self.rear + 1) % self.n
        self.size += 1
        return self




  def 						A__  (       self      )						->				List[Any]:
        '''simple docstring'''






        if self.size == 0:
              raise Exception('UNDERFLOW'      )

        _lowercase			 =self.array[self.front]
        _lowercase			 =None
        _lowercase			 =(self.front + 1) % self.n
        self.size -= 1
        return temp





def   a   (    A__			:     Optional[int]  )					->   Tuple:





      """simple docstring"""



      _lowercase			 =[0] * len(A__  )
      _lowercase			 =[]
      _lowercase			 =[]
      _lowercase			 =0

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

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

      while queue:
            _lowercase			 =queue.pop(0  )
            cnt += 1
            topo.append(A__  )
            for x in graph[vertex]:
                  indegree[x] -= 1
                  if indegree[x] == 0:
                        queue.append(A__  )

      if cnt != len(A__  ):
            print('Cycle exists'  )
      else:
            print(A__  )


# Adjacency List of Graph
lowercase_             =     {0: [1, 2], 1: [3], 2: [3], 3: [4, 5], 4: [], 5: []}







topological_sort(graph)


