


from __future__ import annotations

from typing import Any







class        snake_case_   (lowerCamelCase_      ):
					pass







class        snake_case_   :
					def __init__(      self   :List[Any]			,__snake_case   :Any      )					->    None:
												a__             =     data
												a__             =     None
					def __iter__(      self   :Any      )					->    Dict:
												a__             =     self
												a__             =     []
												while node:
																			if node in visited:
																										raise ContainsLoopError
																			visited.append(__snake_case      )
																			yield node.data
																			a__             =     node.next_node



					@property
					def  lowerCamelCase__(      self   :Optional[int]      )					->    bool:
												try:
																			list(self      )
																			return False
												except ContainsLoopError:
																			return True


if __name__ == "__main__":
						snake_case							:       int     			=      Node(1)
						snake_case							:       int     			=      Node(2)
						snake_case							:       List[Any]     			=      Node(3)
						snake_case							:       Dict     			=      Node(4)
						print(root_node.has_loop)  # False
						snake_case							:       Optional[Any]     			=      root_node.next_node
						print(root_node.has_loop)  # True

						snake_case							:       Union[str, Any]     			=      Node(5)
						snake_case							:       List[Any]     			=      Node(6)
						snake_case							:       str     			=      Node(5)
						snake_case							:       int     			=      Node(6)
						print(root_node.has_loop)  # False

						snake_case							:       Optional[int]     			=      Node(1)
						print(root_node.has_loop)  # False








def 							__lowercase   ( __lowerCAmelCase							:				list[int]   ):
							a__             =     []
							if len(__lowerCAmelCase   ) == 1:
														return [nums.copy()]
							for _ in range(len(__lowerCAmelCase   )   ):
														a__             =     nums.pop(0   )
														a__             =     permute(__lowerCAmelCase   )
														for perm in permutations:
																					perm.append(__lowerCAmelCase   )
														result.extend(__lowerCAmelCase   )
														nums.append(__lowerCAmelCase   )
							return result






def 							__lowercase   ( __lowerCAmelCase							:				Optional[int]   ):

							def backtrack(__lowerCAmelCase							:				Any   ):
														if start == len(__lowerCAmelCase   ) - 1:
																					output.append(nums[:]   )
														else:
																					for i in range(__lowerCAmelCase					,    len(__lowerCAmelCase   )   ):
																												a__      ,					a__             =     nums[i], nums[start]
																												backtrack(start + 1   )
																												a__      ,					a__             =     nums[i], nums[start]  # backtrack

							a__             =     []
							backtrack(0   )
							return output


if __name__ == "__main__":
						import doctest

						# use res to print the data in permute2 function
						snake_case							:       Optional[Any]     			=      permutea([1, 2, 3])
						print(res)
						doctest.testmod()




