'''simple docstring'''






class        A__				:





   """simple docstring"""





   def __init__(					self	:						str     )			->       Optional[Any]:







      """simple docstring"""




      _UpperCAmelCase				:      Any				=  {}




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







      """simple docstring"""




      print(self.vertex     )
      for i in self.vertex:
         print(A_		,	" -> "		,	" -> ".join([str(A_     ) for j in self.vertex[i]]     )     )




   def      _lowerCAmelCase						(					self	:						Optional[int]		,	lowerCAmelCase__	:						Tuple		,	lowerCAmelCase__	:						int     )			->       List[str]:







      """simple docstring"""




      if from_vertex in self.vertex:
         self.vertex[from_vertex].append(A_     )
      else:
         # else make a new vertex
         _UpperCAmelCase				:      int				=  [to_vertex]




   def      _lowerCAmelCase						(					self	:						List[str]     )			->       List[str]:







      """simple docstring"""




      _UpperCAmelCase				:      Tuple				=  [False] * len(self.vertex     )

      # call the recursive helper function
      for i in range(len(self.vertex     )     ):
         if not visited[i]:
            self.dfs_recursive(A_		,	A_     )




   def      _lowerCAmelCase						(					self	:						Optional[Any]		,	lowerCAmelCase__	:						Any		,	lowerCAmelCase__	:						Optional[int]     )			->       Any:







      """simple docstring"""




      _UpperCAmelCase				:      str				=  True

      print(A_		,	end=" "     )

      # Recur for all the vertices that are adjacent to this node
      for i in self.vertex:
         if not visited[i]:
            self.dfs_recursive(A_		,	A_     )


if __name__ == "__main__":
     __a									=   Graph()
     g.add_edge(0, 1)
     g.add_edge(0, 2)
     g.add_edge(1, 2)
     g.add_edge(2, 0)
     g.add_edge(2, 3)
     g.add_edge(3, 3)

     g.print_graph()
     print('DFS:')
     g.dfs()

     # OUTPUT:
     # 0  ->  1 -> 2
     # 1  ->  2
     # 2  ->  0 -> 3
     # 3  ->  3
     # DFS:
     #  0 1 2 3



# A Bipartite Graph is a graph whose vertices can be divided into two independent sets,
# U and V such that every edge (u, v) either connects a vertex from U to V or a vertex
# from V to U. In other words, for every edge (u, v), either u belongs to U and v to V,
# or u belongs to V and v to U. We can also say that there is no edge that connects
# vertices of same set.




def    a__    (		snake_case__					:							Dict     ):
  _UpperCAmelCase		:							str							=     [False] * len(snake_case__     )
  _UpperCAmelCase		:							str							=     [-1] * len(snake_case__     )

  def dfs(snake_case__					:							Dict						,   snake_case__					:							Optional[Any]     ):
    _UpperCAmelCase		:							str							=     True
    _UpperCAmelCase		:							Optional[Any]							=     c
    for u in graph[v]:
      if not visited[u]:
        dfs(snake_case__						,   1 - c     )

  for i in range(len(snake_case__     )     ):
    if not visited[i]:
      dfs(snake_case__						,   0     )

  for i in range(len(snake_case__     )     ):
    for j in graph[i]:
      if color[i] == color[j]:
        return False

  return True


# Adjacency list of graph
SCREAMING_SNAKE_CASE__					:     Optional[Any]       =     {0: [1, 3], 1: [0, 2], 2: [1, 3], 3: [0, 2], 4: []}





print(check_bipartite_dfs(graph))





