



"""simple docstring"""


from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt







def  lowercase	(      _SCREAMING_SNAKE_CASE   :						List[Any]				):






				'''simple docstring'''



				_UpperCAmelCase					=    int(number**0.5				)
				return number == sq * sq







def  lowercase	(      _SCREAMING_SNAKE_CASE   :						int					,     _SCREAMING_SNAKE_CASE   :						str					,     _SCREAMING_SNAKE_CASE   :						List[Any]					,     _SCREAMING_SNAKE_CASE   :						Any					,     _SCREAMING_SNAKE_CASE   :						List[Any]					,     _SCREAMING_SNAKE_CASE   :						List[str]				):






				'''simple docstring'''



				_UpperCAmelCase					=    x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
				_UpperCAmelCase					=    x_den * y_den * z_den
				_UpperCAmelCase					=    gcd(__UpperCamelCase					,     __UpperCamelCase				)
				top //= hcf
				bottom //= hcf
				return top, bottom







def  lowercase	(      _SCREAMING_SNAKE_CASE   :						Union[str, Any] = 35				):






				'''simple docstring'''



				_UpperCAmelCase					=    set()
				_UpperCAmelCase					=    42
				_UpperCAmelCase					=    Fraction(0				)
				_UpperCAmelCase					=    42

				for x_num in range(1					,     order + 1				):
								for x_den in range(x_num + 1					,     order + 1				):
												for y_num in range(1					,     order + 1				):
																for y_den in range(y_num + 1					,     order + 1				):
																				# n=1
																				_UpperCAmelCase					=    x_num * y_den + x_den * y_num
																				_UpperCAmelCase					=    x_den * y_den
																				_UpperCAmelCase					=    gcd(__UpperCamelCase					,     __UpperCamelCase				)
																				z_num //= hcf
																				z_den //= hcf
																				if 0 < z_num < z_den <= order:
																								_UpperCAmelCase					=    add_three(
																								    __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase				)
																								unique_s.add(__UpperCamelCase				)

																				# n=2
																				_UpperCAmelCase					=    (
																				    x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
																				)
																				_UpperCAmelCase					=    x_den * x_den * y_den * y_den
																				if is_sq(__UpperCamelCase				) and is_sq(__UpperCamelCase				):
																								_UpperCAmelCase					=    int(sqrt(__UpperCamelCase				)				)
																								_UpperCAmelCase					=    int(sqrt(__UpperCamelCase				)				)
																								_UpperCAmelCase					=    gcd(__UpperCamelCase					,     __UpperCamelCase				)
																								z_num //= hcf
																								z_den //= hcf
																								if 0 < z_num < z_den <= order:
																												_UpperCAmelCase					=    add_three(
																												    __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase				)
																												unique_s.add(__UpperCamelCase				)

                    # n=-1
																				_UpperCAmelCase					=    x_num * y_num
																				_UpperCAmelCase					=    x_den * y_num + x_num * y_den
																				_UpperCAmelCase					=    gcd(__UpperCamelCase					,     __UpperCamelCase				)
																				z_num //= hcf
																				z_den //= hcf
																				if 0 < z_num < z_den <= order:
																								_UpperCAmelCase					=    add_three(
																								    __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase				)
																								unique_s.add(__UpperCamelCase				)

																				# n=2
																				_UpperCAmelCase					=    x_num * x_num * y_num * y_num
																				_UpperCAmelCase					=    (
																				    x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
																				)
																				if is_sq(__UpperCamelCase				) and is_sq(__UpperCamelCase				):
																								_UpperCAmelCase					=    int(sqrt(__UpperCamelCase				)				)
																								_UpperCAmelCase					=    int(sqrt(__UpperCamelCase				)				)
																								_UpperCAmelCase					=    gcd(__UpperCamelCase					,     __UpperCamelCase				)
																								z_num //= hcf
																								z_den //= hcf
																								if 0 < z_num < z_den <= order:
																												_UpperCAmelCase					=    add_three(
																												    __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase					,     __UpperCamelCase				)
																												unique_s.add(__UpperCamelCase				)

				for num, den in unique_s:
								total += Fraction(__UpperCamelCase					,     __UpperCamelCase				)

				return total.denominator + total.numerator


if __name__ == "__main__":
					print(f'''{solution() = }''')








"""simple docstring"""


import operator







def  lowercase	(      _SCREAMING_SNAKE_CASE   :						list					,     _SCREAMING_SNAKE_CASE   :						bool = False					,     _SCREAMING_SNAKE_CASE   :						list | None = None				):






				'''simple docstring'''



				_UpperCAmelCase					=    operator.lt if reverse else operator.gt
				_UpperCAmelCase					=    solution or []

				if not arr:
								return solution

				_UpperCAmelCase					=    [arr.pop(0				)]
				for i, item in enumerate(_SCREAMING_SNAKE_CASE				):
								if _operator(_SCREAMING_SNAKE_CASE					,     sublist[-1]				):
												sublist.append(_SCREAMING_SNAKE_CASE				)
												arr.pop(_SCREAMING_SNAKE_CASE				)

    #  merging sublist into solution list
				if not solution:
								solution.extend(_SCREAMING_SNAKE_CASE				)
				else:
								while sublist:
												_UpperCAmelCase					=    sublist.pop(0				)
												for i, xx in enumerate(_SCREAMING_SNAKE_CASE				):
																if not _operator(_SCREAMING_SNAKE_CASE					,     _SCREAMING_SNAKE_CASE				):
																				solution.insert(_SCREAMING_SNAKE_CASE					,     _SCREAMING_SNAKE_CASE				)
																				break
												else:
																solution.append(_SCREAMING_SNAKE_CASE				)

				strand_sort(_SCREAMING_SNAKE_CASE					,     _SCREAMING_SNAKE_CASE					,     _SCREAMING_SNAKE_CASE				)
				return solution


if __name__ == "__main__":
					assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5]
					assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]



