






from __future__ import annotations

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



@total_ordering
class 				_UpperCamelCase      (a_      ):


      def __lt__(						self       ,    __UpperCamelCase						)->						List[str]:
           return self[-1] < other[-1]


      def __eq__(						self       ,    __UpperCamelCase						)->						str:
           return self[-1] == other[-1]





def    __lowerCAmelCase   (    __snake_case							):
     __lowerCAmelCase             =       []
     # sort into stacks
     for element in collection:
          __lowerCAmelCase             =       Stack([element]							)
          __lowerCAmelCase             =       bisect_left(__snake_case       ,			__snake_case							)
          if i != len(__snake_case							):
               stacks[i].append(__snake_case							)
          else:
               stacks.append(__snake_case							)

    # use a heap-based merge to merge stack efficiently
     __lowerCAmelCase             =       merge(*(reversed(__snake_case							) for stack in stacks)							)
     return collection


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














from __future__ import annotations





def    __lowerCAmelCase   (    __snake_case							):
     __lowerCAmelCase             =       len(__snake_case							)
     # We need to create solution object to save path.
     __lowerCAmelCase             =       [[0 for _ in range(__snake_case							)] for _ in range(__snake_case							)]
     __lowerCAmelCase             =       run_maze(__snake_case       ,			0       ,			0       ,			__snake_case							)
     if solved:
          print("\n".join(str(__snake_case							) for row in solutions							)							)
     else:
          print("No solution exists!"							)
     return solved





def    __lowerCAmelCase   (    __snake_case       ,			__snake_case       ,			__snake_case       ,			__snake_case							):
     __lowerCAmelCase             =       len(__snake_case							)
     # Final check point.
     if i == j == (size - 1):
          __lowerCAmelCase             =       1
          return True

     __lowerCAmelCase             =       (not i < 0) and (not j < 0)  # Check lower bounds
     __lowerCAmelCase             =       (i < size) and (j < size)  # Check upper bounds

     if lower_flag and upper_flag:
          # check for already visited and block points.
          __lowerCAmelCase             =       (not solutions[i][j]) and (not maze[i][j])
          if block_flag:
               # check visited
               __lowerCAmelCase             =       1

               # check for directions
               if (
                   run_maze(__snake_case       ,			i + 1       ,			__snake_case       ,			__snake_case							)
                   or run_maze(__snake_case       ,			__snake_case       ,			j + 1       ,			__snake_case							)
                   or run_maze(__snake_case       ,			i - 1       ,			__snake_case       ,			__snake_case							)
                   or run_maze(__snake_case       ,			__snake_case       ,			j - 1       ,			__snake_case							)
               ):
                    return True

               __lowerCAmelCase             =       0
               return False
     return False


if __name__ == "__main__":
 import doctest

 doctest.testmod()






