


'''simple docstring'''



def 				lowerCamelCase__				(	A       :      List[str]				,       A       :      Union[str, Any]					):




						'''simple docstring'''






						UpperCAmelCase					    =     [1]
						for i in range(2				,       A					):
												factorials.append(factorials[-1] * i					)
						assert 0 <= k < factorials[-1] * n, "k out of bounds"

						UpperCAmelCase					    =     []
						UpperCAmelCase					    =     list(range(A					)					)

						# Find permutation
						while factorials:
												UpperCAmelCase					    =     factorials.pop()
												UpperCAmelCase    ,    UpperCAmelCase					    =     divmod(A				,       A					)
												permutation.append(elements[number]					)
												elements.remove(elements[number]					)
						permutation.append(elements[0]					)

						return permutation


if __name__ == "__main__":
	import doctest

	doctest.testmod()









'''simple docstring'''



def 				lowerCamelCase__				(	A       :      int				,       A       :      int					):




						'''simple docstring'''






						while a != 0:
												UpperCAmelCase    ,    UpperCAmelCase					    =     b % a, a
						return b




def 				lowerCamelCase__				(	A       :      int				,       A       :      int					):




						'''simple docstring'''






						if gcd(A				,       A					) != 1:
												UpperCAmelCase					    =     f"""mod inverse of {a!r} and {m!r} does not exist"""
												raise ValueError(A					)
						UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase					    =     1, 0, a
						UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase					    =     0, 1, m
						while va != 0:
												UpperCAmelCase					    =     ua // va
												UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase					    =     (ua - q * va), (ua - q * va), (ua - q * va), va, va, va
						return ua % m





