




'''simple docstring'''



class       lowerCAmelCase				:


       def __init__(				self      ,					__SCREAMING_SNAKE_CASE					) ->					None:



            '''simple docstring'''




            __snake_case         =					data
            __snake_case         =					42
            __snake_case         =					42







def      _UpperCamelCase	(_lowerCamelCase							:       Node		)->				None:




     '''simple docstring'''





     __snake_case         =					0
     __snake_case         =					x







def      _UpperCamelCase	(_lowerCamelCase							:       Node				,		_lowerCamelCase							:       Node		)->				None:




     '''simple docstring'''





     __snake_case   ,      __snake_case         =					find_set(_lowerCamelCase		), find_set(_lowerCamelCase		)
     if x == y:
          return

     elif x.rank > y.rank:
          __snake_case         =					x
     else:
          __snake_case         =					y
          if x.rank == y.rank:
               y.rank += 1







def      _UpperCamelCase	(_lowerCamelCase							:       Node		)->				Node:




     '''simple docstring'''





     if x != x.parent:
          __snake_case         =					find_set(x.parent		)
     return x.parent







def      _UpperCamelCase	(_lowerCamelCase							:       Node		)->				set:




     '''simple docstring'''





     __snake_case         =					({0, 1, 2}, {3, 4, 5})
     for s in sets:
          if node.data in s:
               return s
     __snake_case         =					f'''{node.data} is not in {sets}'''
     raise ValueError(_lowerCamelCase		)







def      _UpperCamelCase	()->				None:




     '''simple docstring'''





     __snake_case         =					[Node(_lowerCamelCase		) for i in range(6		)]
     for v in vertex:
          make_set(_lowerCamelCase		)

     union_set(vertex[0]				,		vertex[1]		)
     union_set(vertex[1]				,		vertex[2]		)
     union_set(vertex[3]				,		vertex[4]		)
     union_set(vertex[3]				,		vertex[5]		)

     for nodea in vertex:
          for nodea in vertex:
               if find_python_set(_lowerCamelCase		).isdisjoint(find_python_set(_lowerCamelCase		)		):
                    assert find_set(_lowerCamelCase		) != find_set(_lowerCamelCase		)
               else:
                    assert find_set(_lowerCamelCase		) == find_set(_lowerCamelCase		)


if __name__ == "__main__":
     test_disjoint_set()









'''simple docstring'''



from __future__ import annotations

from collections.abc import Iterator
from typing import Any





class       lowerCAmelCase				:


       def __init__(				self      ,					__SCREAMING_SNAKE_CASE					) ->					None:



            '''simple docstring'''




            __snake_case         =					data
            __snake_case         =					None




       def __str__(				self					) ->					str:



            '''simple docstring'''




            return F'''{self.data}'''





class       lowerCAmelCase				:


       def __init__(				self					) ->					None:



            '''simple docstring'''




            __snake_case         =					None
            __snake_case         =					None


       def __iter__(				self					) ->					Iterator[Any]:



            '''simple docstring'''




            __snake_case         =					self.front
            while node:
                 yield node.data
                 __snake_case         =					node.next


       def __len__(				self					) ->					int:



            '''simple docstring'''




            return len(tuple(iter(self					)					)					)


       def __str__(				self					) ->					str:



            '''simple docstring'''




            return " <- ".join(str(__SCREAMING_SNAKE_CASE					) for item in self					)


       def  lowerCAmelCase (				self					) ->					bool:



            '''simple docstring'''




            return len(self					) == 0


       def  lowerCAmelCase (				self      ,					__SCREAMING_SNAKE_CASE					) ->					None:



            '''simple docstring'''




            __snake_case         =					Node(__SCREAMING_SNAKE_CASE					)
            if self.is_empty():
                 __snake_case         =					__snake_case         =					node
            else:
                 assert isinstance(self.rear      ,					__SCREAMING_SNAKE_CASE					)
                 __snake_case         =					node
                 __snake_case         =					node


       def  lowerCAmelCase (				self					) ->					Any:



            '''simple docstring'''




            if self.is_empty():
                 raise IndexError('''dequeue from empty queue'''					)
            assert isinstance(self.front      ,					__SCREAMING_SNAKE_CASE					)
            __snake_case         =					self.front
            __snake_case         =					self.front.next
            if self.front is None:
                 __snake_case         =					None
            return node.data




       def  lowerCAmelCase (				self					) ->					None:



            '''simple docstring'''




            __snake_case         =					__snake_case         =					None


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

     testmod()






