


"""simple docstring"""





from __future__ import annotations

from collections import deque
from collections.abc import Sequence
from dataclasses import dataclass
from typing import Any




@dataclass
class 							snake_case							:

      '''simple docstring'''



      _A     :       int
      _A     :       Node | None         =       None
      _A     :       Node | None         =       None


def       lowerCamelCase_       (   )						->Node | None:





  """simple docstring"""


  __UpperCAmelCase    :						str       =						Node(1  )
  __UpperCAmelCase    :						List[Any]       =						Node(2  )
  __UpperCAmelCase    :						List[Any]       =						Node(3  )
  __UpperCAmelCase    :						List[Any]       =						Node(4  )
  __UpperCAmelCase    :						int       =						Node(5  )
  return tree


def       lowerCamelCase_       (   UpperCAmelCase_  )						->list[int]:





  """simple docstring"""


  return [root.data, *preorder(root.left  ), *preorder(root.right  )] if root else []


def       lowerCamelCase_       (   UpperCAmelCase_  )						->list[int]:





  """simple docstring"""


  return postorder(root.left  ) + postorder(root.right  ) + [root.data] if root else []


def       lowerCamelCase_       (   UpperCAmelCase_  )						->list[int]:





  """simple docstring"""


  return [*inorder(root.left  ), root.data, *inorder(root.right  )] if root else []


def       lowerCamelCase_       (   UpperCAmelCase_  )						->int:





  """simple docstring"""


  return (max(height(root.left  )  ,			height(root.right  )  ) + 1) if root else 0


def       lowerCamelCase_       (   UpperCAmelCase_  )						->Sequence[Node | None]:





  """simple docstring"""


  __UpperCAmelCase    :						list[Any]       =						[]

  if root is None:
    return output

  __UpperCAmelCase    :						Any       =						deque([root]  )

  while process_queue:
    __UpperCAmelCase    :						str       =						process_queue.popleft()
    output.append(node.data  )

    if node.left:
      process_queue.append(node.left  )
    if node.right:
      process_queue.append(node.right  )
  return output


def       lowerCamelCase_       (   UpperCAmelCase_  ,			UpperCAmelCase_  )						->Sequence[Node | None]:





  """simple docstring"""


  __UpperCAmelCase    :						list[Any]       =						[]

  def populate_output(UpperCAmelCase_  ,			UpperCAmelCase_  ) -> None:
    if not root:
      return
    if level == 1:
      output.append(root.data  )
    elif level > 1:
      populate_output(root.left  ,			level - 1  )
      populate_output(root.right  ,			level - 1  )

  populate_output(UpperCAmelCase_  ,			UpperCAmelCase_  )
  return output


def       lowerCamelCase_       (   UpperCAmelCase_  ,			UpperCAmelCase_  )						->Sequence[Node | None]:





  """simple docstring"""


  __UpperCAmelCase    :						list[Any]       =						[]

  def populate_output(UpperCAmelCase_  ,			UpperCAmelCase_  ) -> None:
    if root is None:
      return
    if level == 1:
      output.append(root.data  )
    elif level > 1:
      populate_output(root.right  ,			level - 1  )
      populate_output(root.left  ,			level - 1  )

  populate_output(UpperCAmelCase_  ,			UpperCAmelCase_  )
  return output


def       lowerCamelCase_       (   UpperCAmelCase_  )						->Sequence[Node | None] | list[Any]:





  """simple docstring"""


  if root is None:
    return []

  __UpperCAmelCase    :						list[Sequence[Node | None]]       =						[]

  __UpperCAmelCase    :						Any       =						0
  __UpperCAmelCase    :						Optional[int]       =						height(UpperCAmelCase_  )

  for h in range(1  ,			height_tree + 1  ):
    if not flag:
      output.append(get_nodes_from_left_to_right(UpperCAmelCase_  ,			UpperCAmelCase_  )  )
      __UpperCAmelCase    :						str       =						1
    else:
      output.append(get_nodes_from_right_to_left(UpperCAmelCase_  ,			UpperCAmelCase_  )  )
      __UpperCAmelCase    :						Optional[int]       =						0

  return output


def       lowerCamelCase_       (   )						->None:  # Main function for testing.





  """simple docstring"""


  __UpperCAmelCase    :						int       =						make_tree()
  print(f'''In-order Traversal: {inorder(UpperCAmelCase_  )}'''  )
  print(f'''Pre-order Traversal: {preorder(UpperCAmelCase_  )}'''  )
  print(f'''Post-order Traversal: {postorder(UpperCAmelCase_  )}'''  ,			'''\n'''  )

  print(f'''Height of Tree: {height(UpperCAmelCase_  )}'''  ,			'''\n'''  )

  print('''Complete Level Order Traversal: '''  )
  print(level_order(UpperCAmelCase_  )  ,			'''\n'''  )

  print('''Level-wise order Traversal: '''  )

  for level in range(1  ,			height(UpperCAmelCase_  ) + 1  ):
    print(f'''Level {level}:'''  ,			get_nodes_from_left_to_right(UpperCAmelCase_  ,			level=UpperCAmelCase_  )  )

  print('''\nZigZag order Traversal: '''  )
  print(zigzag(UpperCAmelCase_  )  )


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  main()






"""simple docstring"""





def       lowerCamelCase_       (   UpperCAmelCase_ = 10_00  )						->int:





  """simple docstring"""


  return sum(2 * a * ((a - 1) // 2) for a in range(3  ,			n + 1  )  )


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