



'''simple docstring'''





from __future__ import annotations

from bisect import bisect_left
from functools import total_ordering
from heapq import merge



@total_ordering
class  lowerCamelCase__    (							_UpperCAmelCase):




		'''simple docstring'''



		def __lt__(self	,__lowerCamelCase				)  ->    Dict:

						"""simple docstring"""






						return self[-1] < other[-1]



		def __eq__(self	,__lowerCamelCase				)  ->    Optional[Any]:

						"""simple docstring"""






						return self[-1] == other[-1]






def 			lowerCAmelCase__	(					lowerCamelCase_	:	list):





				'''simple docstring'''

				lowerCAmelCase__  :       list[Stack]				=  []
				# sort into stacks
				for element in collection:
								lowerCAmelCase__  :       List[str]				=  Stack([element])
								lowerCAmelCase__  :       List[str]				=  bisect_left(a_ ,a_)
								if i != len(a_):
												stacks[i].append(a_)
								else:
												stacks.append(a_)

    # use a heap-based merge to merge stack efficiently
				lowerCAmelCase__  :       int				=  merge(*(reversed(a_) for stack in stacks))
				return collection


if __name__ == "__main__":
							__snake_case       :	int            =input('Enter numbers separated by a comma:\n').strip()
							__snake_case       :	str            =[int(item) for item in user_input.split(',')]
							print(patience_sort(unsorted))






from __future__ import annotations






def 			lowerCAmelCase__	(					lowerCamelCase_	:	int):





				'''simple docstring'''

				lowerCAmelCase__  :       Optional[int]				=  str(lowerCamelCase_)
				return len(lowerCamelCase_) == 9 and set(lowerCamelCase_) == set('''123456789''')






def 			lowerCAmelCase__	(					):





				'''simple docstring'''

				for base_num in range(9999 ,4999 ,-1):
								lowerCAmelCase__  :       Union[str, Any]				=  100002 * base_num
								if is_9_pandigital(lowerCamelCase_):
												return candidate

				for base_num in range(333 ,99 ,-1):
								lowerCAmelCase__  :       Any				=  1002003 * base_num
								if is_9_pandigital(lowerCamelCase_):
												return candidate

				return None


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

