



from __future__ import annotations

from collections import defaultdict
from dataclasses import dataclass

@dataclass
class 	__snake_case :







							'''simple docstring'''






							UpperCamelCase__			: int
							UpperCamelCase__			: TreeNode | None             =   None
							UpperCamelCase__			: TreeNode | None             =   None




def      A_ (		):

				"""simple docstring"""
				return TreeNode(3	,						TreeNode(9						)	,						TreeNode(20	,						TreeNode(15						)	,						TreeNode(7						)						)						)

def      A_ (		__a       :			TreeNode						):

				"""simple docstring"""

				def depth_first_search(
				    __a       :			TreeNode | None	,						__a       :			int	,						__a       :			list[int]						) -> None:
								if not root:
												return

								if depth == len(__a						):
												right_view.append(root.val						)

								depth_first_search(root.right	,						depth + 1	,						__a						)
								depth_first_search(root.left	,						depth + 1	,						__a						)

				a__			 =						[]
				if not root:
								return right_view

				depth_first_search(__a	,						0	,						__a						)
				return right_view

def      A_ (		__a       :			TreeNode						):

				"""simple docstring"""

				def depth_first_search(
				    __a       :			TreeNode | None	,						__a       :			int	,						__a       :			list[int]						) -> None:
								if not root:
												return

								if depth == len(__a						):
												left_view.append(root.val						)

								depth_first_search(root.left	,						depth + 1	,						__a						)
								depth_first_search(root.right	,						depth + 1	,						__a						)

				a__			 =						[]
				if not root:
								return left_view

				depth_first_search(__a	,						0	,						__a						)
				return left_view

def      A_ (		__a       :			TreeNode						):

				"""simple docstring"""

				def breadth_first_search(__a       :			TreeNode	,						__a       :			list[int]						) -> None:
								a__			 =						[(root, 0)]
								a__			 =						defaultdict(__a						)

								while queue:
												a__			 =						queue.pop(0						)
												a__ ,     a__			 =						first

												lookup[hd].append(node.val						)

												if node.left:
																queue.append((node.left, hd - 1)						)
												if node.right:
																queue.append((node.right, hd + 1)						)

								for pair in sorted(lookup.items()	,						key=lambda __a						: each[0]						):
												top_view.append(pair[1][0]						)

				a__			 =						[]
				if not root:
								return top_view

				breadth_first_search(__a	,						__a						)
				return top_view

def      A_ (		__a       :			TreeNode						):

				"""simple docstring"""
				from collections import defaultdict

				def breadth_first_search(__a       :			TreeNode	,						__a       :			list[int]						) -> None:
								a__			 =						[(root, 0)]
								a__			 =						defaultdict(__a						)

								while queue:
												a__			 =						queue.pop(0						)
												a__ ,     a__			 =						first
												lookup[hd].append(node.val						)

												if node.left:
																queue.append((node.left, hd - 1)						)
												if node.right:
																queue.append((node.right, hd + 1)						)

								for pair in sorted(lookup.items()	,						key=lambda __a						: each[0]						):
												bottom_view.append(pair[1][-1]						)

				a__			 =						[]
				if not root:
								return bottom_view

				breadth_first_search(__a	,						__a						)
				return bottom_view


if __name__ == "__main__":
	import doctest

	doctest.testmod()






def      A_ (		__a       :			int						):

				"""simple docstring"""
				if number != int(__a						):
								raise ValueError("""factorial() only accepts integral values"""						)
				if number < 0:
								raise ValueError("""factorial() not defined for negative values"""						)
				a__			 =						1
				for i in range(1	,						number + 1						):
								value *= i
				return value

def      A_ (		__a       :			int						):

				"""simple docstring"""
				if not isinstance(__a	,						__a						):
								raise ValueError("""factorial() only accepts integral values"""						)
				if n < 0:
								raise ValueError("""factorial() not defined for negative values"""						)
				return 1 if n == 0 or n == 1 else n * factorial(n - 1						)


if __name__ == "__main__":
	import doctest

	doctest.testmod()

	UpperCAmelCase								=   int(input("""Enter a positive integer: """).strip() or 0)
	print(f"""factorial{n} is {factorial(n)}""")

