


from __future__ import annotations

from random import random



class        a					:





     def __init__(    self					:				int    ,	SCREAMING_SNAKE_CASE_					:				int | None = None							):
        __lowerCamelCase:				Union[str, Any]     =	value
        __lowerCamelCase:				Union[str, Any]     =	random()
        __lowerCamelCase:				Node | None     =	None
        __lowerCamelCase:				Node | None     =	None





     def __repr__(    self					:				List[str]							):
        from pprint import pformat

        if self.left is None and self.right is None:
           return F'\'{self.value}: {self.prior:.5}\''
        else:
           return pformat(
               {F'{self.value}: {self.prior:.5}': (self.left, self.right)}    ,	indent=1							)







     def __str__(    self					:				Any							):
        __lowerCamelCase:				Optional[int]     =	str(self.value							) + " "
        __lowerCamelCase:				Optional[Any]     =	str(self.left or """"""							)
        __lowerCamelCase:				Union[str, Any]     =	str(self.right or """"""							)
        return value + left + right



def     __lowerCAmelCase						(							snake_case	:    Node | None						,      snake_case	:    int )       ->							tuple[Node | None, Node | None]:

   '''simple docstring'''





   if root is None:  # None tree is split into 2 Nones
      return None, None
   elif root.value is None:
      return None, None
   else:
      if value < root.value:
         __lowerCamelCase:				Dict     =	split(root.left						,      _lowerCamelCase )
         return left, root
      else:
         __lowerCamelCase:				Any     =	split(root.right						,      _lowerCamelCase )
         return root, right



def     __lowerCAmelCase						(							snake_case	:    Node | None						,      snake_case	:    Node | None )       ->							Node | None:

   '''simple docstring'''





   if (not left) or (not right):  # If one node is None, return the other
      return left or right
   elif left.prior < right.prior:
      __lowerCamelCase:				int     =	merge(left.right						,      _lowerCamelCase )
      return left
   else:
      __lowerCamelCase:				List[Any]     =	merge(_lowerCamelCase						,      right.left )
      return right



def     __lowerCAmelCase						(							snake_case	:    Node | None						,      snake_case	:    int )       ->							Node | None:

   '''simple docstring'''





   __lowerCamelCase:				Optional[Any]     =	Node(_lowerCamelCase )
   __lowerCamelCase:				str     =	split(_lowerCamelCase						,      _lowerCamelCase )
   return merge(merge(_lowerCamelCase						,      _lowerCamelCase )						,      _lowerCamelCase )



def     __lowerCAmelCase						(							snake_case	:    Node | None						,      snake_case	:    int )       ->							Node | None:

   '''simple docstring'''





   __lowerCamelCase:				List[Any]     =	split(_lowerCamelCase						,      value - 1 )
   __lowerCamelCase:				int     =	split(_lowerCamelCase						,      _lowerCamelCase )
   return merge(_lowerCamelCase						,      _lowerCamelCase )



def     __lowerCAmelCase						(							snake_case	:    Node | None )       ->							None:

   '''simple docstring'''





   if not root:  # None
      return
   else:
      inorder(root.left )
      print(root.value						,      end=""",""" )
      inorder(root.right )



def     __lowerCAmelCase						(							snake_case	:    Node | None						,      snake_case	:    str )       ->							Node | None:

   '''simple docstring'''





   for arg in args.split():
      if arg[0] == "+":
         __lowerCamelCase:				Optional[int]     =	insert(_lowerCamelCase						,      int(arg[1:] ) )

      elif arg[0] == "-":
         __lowerCamelCase:				Any     =	erase(_lowerCamelCase						,      int(arg[1:] ) )

      else:
         print("""Unknown command""" )

   return root



def     __lowerCAmelCase						(							)       ->							None:

   '''simple docstring'''





   __lowerCamelCase:				Optional[int]     =	None
   print(
       """enter numbers to create a tree, + value to add value into treap, """
       """- value to erase all nodes with value. 'q' to quit. """ )

   __lowerCamelCase:				int     =	input()
   while args != "q":
      __lowerCamelCase:				Union[str, Any]     =	interact_treap(_lowerCamelCase						,      _lowerCamelCase )
      print(_lowerCamelCase )
      __lowerCamelCase:				Union[str, Any]     =	input()

   print("""good by!""" )


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   main()






def     __lowerCAmelCase						(							)       ->							Optional[Any]:
   __lowerCamelCase:				List[str]     =	[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

   __lowerCamelCase:				List[str]     =	6
   __lowerCamelCase:				Optional[int]     =	1
   __lowerCamelCase:				int     =	1901

   __lowerCamelCase:				Tuple     =	0

   while year < 2001:
      day += 7

      if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
         if day > days_per_month[month - 1] and month != 2:
            month += 1
            __lowerCamelCase:				Union[str, Any]     =	day - days_per_month[month - 2]
         elif day > 29 and month == 2:
            month += 1
            __lowerCamelCase:				List[Any]     =	day - 29
      else:
         if day > days_per_month[month - 1]:
            month += 1
            __lowerCamelCase:				Any     =	day - days_per_month[month - 2]

      if month > 12:
         year += 1
         __lowerCamelCase:				Dict     =	1

      if year < 2001 and day == 1:
         sundays += 1
   return sundays


if __name__ == "__main__":
   print(solution())


