
from collections import deque
from math import floor
from random import random
from time import time

class 						__UpperCamelCase    :




	def __init__(		self	:						Tuple							):


		'''simple docstring'''







		UpperCAmelCase_       				=			{}




	def       __A					(		self	:						Dict		,	lowerCAmelCase	:						Optional[int]		,	lowerCAmelCase	:						List[str]		,	lowerCAmelCase	:						Optional[Any]=1							):


		'''simple docstring'''







		if self.graph.get(lowerCamelCase_							):
			if self.graph[u].count([w, v]							) == 0:
				self.graph[u].append([w, v]							)
		else:
			UpperCAmelCase_       				=			[[w, v]]
		if not self.graph.get(lowerCamelCase_							):
			UpperCAmelCase_       				=			[]




	def       __A					(		self	:						Optional[int]							):


		'''simple docstring'''







		return list(self.graph							)




	def       __A					(		self	:						List[str]		,	lowerCAmelCase	:						Optional[int]		,	lowerCAmelCase	:						Optional[Any]							):


		'''simple docstring'''







		if self.graph.get(lowerCamelCase_							):
			for _ in self.graph[u]:
				if _[1] == v:
					self.graph[u].remove(lowerCamelCase_							)




	def       __A					(		self	:						int		,	lowerCAmelCase	:						str=-2		,	lowerCAmelCase	:						List[str]=-1							):


		'''simple docstring'''







		if s == d:
			return []
		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			[]
		if s == -2:
			UpperCAmelCase_       				=			list(self.graph							)[0]
		stack.append(lowerCamelCase_							)
		visited.append(lowerCamelCase_							)
		UpperCAmelCase_       				=			s

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]							) != 0:
				UpperCAmelCase_       				=			s
				for node in self.graph[s]:
					if visited.count(node[1]							) < 1:
						if node[1] == d:
							visited.append(lowerCamelCase_							)
							return visited
						else:
							stack.append(node[1]							)
							visited.append(node[1]							)
							UpperCAmelCase_       				=			node[1]
							break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				if len(lowerCamelCase_							) != 0:
					UpperCAmelCase_       				=			stack[len(lowerCamelCase_							) - 1]
			else:
				UpperCAmelCase_       				=			ss

			# check if se have reached the starting point
			if len(lowerCamelCase_							) == 0:
				return visited




	def       __A					(		self	:						int		,	lowerCAmelCase	:						int=-1							):


		'''simple docstring'''







		if c == -1:
			UpperCAmelCase_       				=			floor(random() * 10_000							) + 10
		for i in range(lowerCamelCase_							):
			# every vertex has max 100 edges
			for _ in range(floor(random() * 102							) + 1							):
				UpperCAmelCase_       				=			floor(random() * c							) + 1
				if n != i:
					self.add_pair(lowerCamelCase_		,	lowerCamelCase_		,	1							)




	def       __A					(		self	:						int		,	lowerCAmelCase	:						int=-2							):


		'''simple docstring'''







		UpperCAmelCase_       				=			deque()
		UpperCAmelCase_       				=			[]
		if s == -2:
			UpperCAmelCase_       				=			list(self.graph							)[0]
		d.append(lowerCamelCase_							)
		visited.append(lowerCamelCase_							)
		while d:
			UpperCAmelCase_       				=			d.popleft()
			if len(self.graph[s]							) != 0:
				for node in self.graph[s]:
					if visited.count(node[1]							) < 1:
						d.append(node[1]							)
						visited.append(node[1]							)
		return visited




	def       __A					(		self	:						Optional[Any]		,	lowerCAmelCase	:						Dict							):


		'''simple docstring'''







		UpperCAmelCase_       				=			0
		for x in self.graph:
			for y in self.graph[x]:
				if y[1] == u:
					count += 1
		return count




	def       __A					(		self	:						List[Any]		,	lowerCAmelCase	:						int							):


		'''simple docstring'''







		return len(self.graph[u]							)




	def       __A					(		self	:						List[Any]		,	lowerCAmelCase	:						List[str]=-2							):


		'''simple docstring'''







		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			[]
		if s == -2:
			UpperCAmelCase_       				=			list(self.graph							)[0]
		stack.append(lowerCamelCase_							)
		visited.append(lowerCamelCase_							)
		UpperCAmelCase_       				=			s
		UpperCAmelCase_       				=			[]

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]							) != 0:
				UpperCAmelCase_       				=			s
				for node in self.graph[s]:
					if visited.count(node[1]							) < 1:
						stack.append(node[1]							)
						visited.append(node[1]							)
						UpperCAmelCase_       				=			node[1]
						break

            # check if all the children are visited
			if s == ss:
				sorted_nodes.append(stack.pop()							)
				if len(lowerCamelCase_							) != 0:
					UpperCAmelCase_       				=			stack[len(lowerCamelCase_							) - 1]
			else:
				UpperCAmelCase_       				=			ss

			# check if se have reached the starting point
			if len(lowerCamelCase_							) == 0:
				return sorted_nodes




	def       __A					(		self	:						int							):


		'''simple docstring'''







		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			list(self.graph							)[0]
		stack.append(lowerCamelCase_							)
		visited.append(lowerCamelCase_							)
		UpperCAmelCase_       				=			-2
		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			s
		UpperCAmelCase_       				=			False
		UpperCAmelCase_       				=			set()

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]							) != 0:
				UpperCAmelCase_       				=			s
				for node in self.graph[s]:
					if (
					    visited.count(node[1]							) > 0
					    and node[1] != parent
					    and indirect_parents.count(node[1]							) > 0
					    and not on_the_way_back
					):
						UpperCAmelCase_       				=			len(lowerCamelCase_							) - 1
						while len_stack >= 0:
							if stack[len_stack] == node[1]:
								anticipating_nodes.add(node[1]							)
								break
							else:
								anticipating_nodes.add(stack[len_stack]							)
								len_stack -= 1
					if visited.count(node[1]							) < 1:
						stack.append(node[1]							)
						visited.append(node[1]							)
						UpperCAmelCase_       				=			node[1]
						break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				UpperCAmelCase_       				=			True
				if len(lowerCamelCase_							) != 0:
					UpperCAmelCase_       				=			stack[len(lowerCamelCase_							) - 1]
			else:
				UpperCAmelCase_       				=			False
				indirect_parents.append(lowerCamelCase_							)
				UpperCAmelCase_       				=			s
				UpperCAmelCase_       				=			ss

			# check if se have reached the starting point
			if len(lowerCamelCase_							) == 0:
				return list(lowerCamelCase_							)




	def       __A					(		self	:						List[Any]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			list(self.graph							)[0]
		stack.append(lowerCamelCase_							)
		visited.append(lowerCamelCase_							)
		UpperCAmelCase_       				=			-2
		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			s
		UpperCAmelCase_       				=			False
		UpperCAmelCase_       				=			set()

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]							) != 0:
				UpperCAmelCase_       				=			s
				for node in self.graph[s]:
					if (
					    visited.count(node[1]							) > 0
					    and node[1] != parent
					    and indirect_parents.count(node[1]							) > 0
					    and not on_the_way_back
					):
						UpperCAmelCase_       				=			len(lowerCamelCase_							) - 1
						while len_stack_minus_one >= 0:
							if stack[len_stack_minus_one] == node[1]:
								anticipating_nodes.add(node[1]							)
								break
							else:
								return True
					if visited.count(node[1]							) < 1:
						stack.append(node[1]							)
						visited.append(node[1]							)
						UpperCAmelCase_       				=			node[1]
						break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				UpperCAmelCase_       				=			True
				if len(lowerCamelCase_							) != 0:
					UpperCAmelCase_       				=			stack[len(lowerCamelCase_							) - 1]
			else:
				UpperCAmelCase_       				=			False
				indirect_parents.append(lowerCamelCase_							)
				UpperCAmelCase_       				=			s
				UpperCAmelCase_       				=			ss

			# check if se have reached the starting point
			if len(lowerCamelCase_							) == 0:
				return False




	def       __A					(		self	:						Union[str, Any]		,	lowerCAmelCase	:						Union[str, Any]=-2		,	lowerCAmelCase	:						Optional[int]=-1							):


		'''simple docstring'''







		UpperCAmelCase_       				=			time()
		self.dfs(lowerCamelCase_		,	lowerCamelCase_							)
		UpperCAmelCase_       				=			time()
		return end - begin




	def       __A					(		self	:						Optional[int]		,	lowerCAmelCase	:						str=-2							):


		'''simple docstring'''







		UpperCAmelCase_       				=			time()
		self.bfs(lowerCamelCase_							)
		UpperCAmelCase_       				=			time()
		return end - begin


class 						__UpperCamelCase    :




	def __init__(		self	:						int							):


		'''simple docstring'''







		UpperCAmelCase_       				=			{}




	def       __A					(		self	:						Any		,	lowerCAmelCase	:						List[Any]		,	lowerCAmelCase	:						Any		,	lowerCAmelCase	:						List[Any]=1							):


		'''simple docstring'''







		if self.graph.get(lowerCamelCase_							):
			# if there already is a edge
			if self.graph[u].count([w, v]							) == 0:
				self.graph[u].append([w, v]							)
		else:
			# if u does not exist
			UpperCAmelCase_       				=			[[w, v]]
		# add the other way
		if self.graph.get(lowerCamelCase_							):
			# if there already is a edge
			if self.graph[v].count([w, u]							) == 0:
				self.graph[v].append([w, u]							)
		else:
			# if u does not exist
			UpperCAmelCase_       				=			[[w, u]]




	def       __A					(		self	:						Tuple		,	lowerCAmelCase	:						Optional[int]		,	lowerCAmelCase	:						List[str]							):


		'''simple docstring'''







		if self.graph.get(lowerCamelCase_							):
			for _ in self.graph[u]:
				if _[1] == v:
					self.graph[u].remove(lowerCamelCase_							)
        # the other way round
		if self.graph.get(lowerCamelCase_							):
			for _ in self.graph[v]:
				if _[1] == u:
					self.graph[v].remove(lowerCamelCase_							)




	def       __A					(		self	:						str		,	lowerCAmelCase	:						Tuple=-2		,	lowerCAmelCase	:						Dict=-1							):


		'''simple docstring'''







		if s == d:
			return []
		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			[]
		if s == -2:
			UpperCAmelCase_       				=			list(self.graph							)[0]
		stack.append(lowerCamelCase_							)
		visited.append(lowerCamelCase_							)
		UpperCAmelCase_       				=			s

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]							) != 0:
				UpperCAmelCase_       				=			s
				for node in self.graph[s]:
					if visited.count(node[1]							) < 1:
						if node[1] == d:
							visited.append(lowerCamelCase_							)
							return visited
						else:
							stack.append(node[1]							)
							visited.append(node[1]							)
							UpperCAmelCase_       				=			node[1]
							break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				if len(lowerCamelCase_							) != 0:
					UpperCAmelCase_       				=			stack[len(lowerCamelCase_							) - 1]
			else:
				UpperCAmelCase_       				=			ss

			# check if se have reached the starting point
			if len(lowerCamelCase_							) == 0:
				return visited




	def       __A					(		self	:						Optional[Any]		,	lowerCAmelCase	:						int=-1							):


		'''simple docstring'''







		if c == -1:
			UpperCAmelCase_       				=			floor(random() * 10_000							) + 10
		for i in range(lowerCamelCase_							):
			# every vertex has max 100 edges
			for _ in range(floor(random() * 102							) + 1							):
				UpperCAmelCase_       				=			floor(random() * c							) + 1
				if n != i:
					self.add_pair(lowerCamelCase_		,	lowerCamelCase_		,	1							)




	def       __A					(		self	:						Tuple		,	lowerCAmelCase	:						str=-2							):


		'''simple docstring'''







		UpperCAmelCase_       				=			deque()
		UpperCAmelCase_       				=			[]
		if s == -2:
			UpperCAmelCase_       				=			list(self.graph							)[0]
		d.append(lowerCamelCase_							)
		visited.append(lowerCamelCase_							)
		while d:
			UpperCAmelCase_       				=			d.popleft()
			if len(self.graph[s]							) != 0:
				for node in self.graph[s]:
					if visited.count(node[1]							) < 1:
						d.append(node[1]							)
						visited.append(node[1]							)
		return visited




	def       __A					(		self	:						Tuple		,	lowerCAmelCase	:						Tuple							):


		'''simple docstring'''







		return len(self.graph[u]							)




	def       __A					(		self	:						str							):


		'''simple docstring'''







		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			list(self.graph							)[0]
		stack.append(lowerCamelCase_							)
		visited.append(lowerCamelCase_							)
		UpperCAmelCase_       				=			-2
		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			s
		UpperCAmelCase_       				=			False
		UpperCAmelCase_       				=			set()

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]							) != 0:
				UpperCAmelCase_       				=			s
				for node in self.graph[s]:
					if (
					    visited.count(node[1]							) > 0
					    and node[1] != parent
					    and indirect_parents.count(node[1]							) > 0
					    and not on_the_way_back
					):
						UpperCAmelCase_       				=			len(lowerCamelCase_							) - 1
						while len_stack >= 0:
							if stack[len_stack] == node[1]:
								anticipating_nodes.add(node[1]							)
								break
							else:
								anticipating_nodes.add(stack[len_stack]							)
								len_stack -= 1
					if visited.count(node[1]							) < 1:
						stack.append(node[1]							)
						visited.append(node[1]							)
						UpperCAmelCase_       				=			node[1]
						break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				UpperCAmelCase_       				=			True
				if len(lowerCamelCase_							) != 0:
					UpperCAmelCase_       				=			stack[len(lowerCamelCase_							) - 1]
			else:
				UpperCAmelCase_       				=			False
				indirect_parents.append(lowerCamelCase_							)
				UpperCAmelCase_       				=			s
				UpperCAmelCase_       				=			ss

			# check if se have reached the starting point
			if len(lowerCamelCase_							) == 0:
				return list(lowerCamelCase_							)




	def       __A					(		self	:						Any							):


		'''simple docstring'''







		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			list(self.graph							)[0]
		stack.append(lowerCamelCase_							)
		visited.append(lowerCamelCase_							)
		UpperCAmelCase_       				=			-2
		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			s
		UpperCAmelCase_       				=			False
		UpperCAmelCase_       				=			set()

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]							) != 0:
				UpperCAmelCase_       				=			s
				for node in self.graph[s]:
					if (
					    visited.count(node[1]							) > 0
					    and node[1] != parent
					    and indirect_parents.count(node[1]							) > 0
					    and not on_the_way_back
					):
						UpperCAmelCase_       				=			len(lowerCamelCase_							) - 1
						while len_stack_minus_one >= 0:
							if stack[len_stack_minus_one] == node[1]:
								anticipating_nodes.add(node[1]							)
								break
							else:
								return True
					if visited.count(node[1]							) < 1:
						stack.append(node[1]							)
						visited.append(node[1]							)
						UpperCAmelCase_       				=			node[1]
						break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				UpperCAmelCase_       				=			True
				if len(lowerCamelCase_							) != 0:
					UpperCAmelCase_       				=			stack[len(lowerCamelCase_							) - 1]
			else:
				UpperCAmelCase_       				=			False
				indirect_parents.append(lowerCamelCase_							)
				UpperCAmelCase_       				=			s
				UpperCAmelCase_       				=			ss

			# check if se have reached the starting point
			if len(lowerCamelCase_							) == 0:
				return False




	def       __A					(		self	:						List[Any]							):


		'''simple docstring'''







		return list(self.graph							)




	def       __A					(		self	:						Dict		,	lowerCAmelCase	:						Union[str, Any]=-2		,	lowerCAmelCase	:						Union[str, Any]=-1							):


		'''simple docstring'''







		UpperCAmelCase_       				=			time()
		self.dfs(lowerCamelCase_		,	lowerCamelCase_							)
		UpperCAmelCase_       				=			time()
		return end - begin




	def       __A					(		self	:						Dict		,	lowerCAmelCase	:						Any=-2							):


		'''simple docstring'''







		UpperCAmelCase_       				=			time()
		self.bfs(lowerCamelCase_							)
		UpperCAmelCase_       				=			time()
		return end - begin


def       __lowerCAmelCase      (						A    ):
	if len(A    ) <= 1:
		return lst

	UpperCAmelCase_       				=			1

	while i < len(A    ):
		if lst[i - 1] <= lst[i]:
			i += 1
		else:
			UpperCAmelCase_				,   UpperCAmelCase_       				=			lst[i], lst[i - 1]
			i -= 1
			if i == 0:
				UpperCAmelCase_       				=			1

	return lst


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