



"""simple docstring"""
from __future__ import annotations

from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any


class 							lowerCamelCase_:





					'''simple docstring'''



					lowercase__      :				Any        =       ('_front', '_back', '_len')


					@dataclass
					class 							lowerCamelCase_:





										'''simple docstring'''



										lowercase__      :				Any        =       None
										lowercase__      :				Deque._Node | None        =       None
										lowercase__      :				Deque._Node | None        =       None


					class 							lowerCamelCase_:





										'''simple docstring'''



										lowercase__      :				List[Any]        =       ('_cur',)

										def __init__(			self ,				lowerCamelCase__      ):
														_lowerCamelCase					     = cur

										def __iter__(			self      ):
														return self





										def 	snake_case__					(			self      ):
														if self._cur is None:
																		# finished iterating
																		raise StopIteration
														_lowerCamelCase					     = self._cur.val
														_lowerCamelCase					     = self._cur.next_node

														return val

					def __init__(			self ,				lowerCamelCase__ = None      ):
									_lowerCamelCase					     = None
									_lowerCamelCase					     = None
									_lowerCamelCase					     = 0

									if iterable is not None:
													# append every value to the deque
													for val in iterable:
																	self.append(lowerCamelCase__      )

					def 	snake_case__					(			self ,				lowerCamelCase__      ):
									_lowerCamelCase					     = self._Node(lowerCamelCase__ ,				lowerCamelCase__ ,				lowerCamelCase__      )
									if self.is_empty():
													# front = back
													_lowerCamelCase					     = _lowerCamelCase					     = node
													_lowerCamelCase					     = 1
									else:
													# connect nodes
													_lowerCamelCase					     = node
													_lowerCamelCase					     = self._back
													_lowerCamelCase					     = node  # assign new back to the new node

													self._len += 1

													# make sure there were no errors
													assert not self.is_empty(), "Error on appending value."

					def 	snake_case__					(			self ,				lowerCamelCase__      ):
									_lowerCamelCase					     = self._Node(lowerCamelCase__ ,				lowerCamelCase__ ,				lowerCamelCase__      )
									if self.is_empty():
													# front = back
													_lowerCamelCase					     = _lowerCamelCase					     = node
													_lowerCamelCase					     = 1
									else:
													# connect nodes
													_lowerCamelCase					     = self._front
													_lowerCamelCase					     = node
													_lowerCamelCase					     = node  # assign new front to the new node

													self._len += 1

													# make sure there were no errors
													assert not self.is_empty(), "Error on appending value."

					def 	snake_case__					(			self ,				lowerCamelCase__      ):
									for val in iterable:
													self.append(lowerCamelCase__      )

					def 	snake_case__					(			self ,				lowerCamelCase__      ):
									for val in iterable:
													self.appendleft(lowerCamelCase__      )

					def 	snake_case__					(			self      ):
									assert not self.is_empty(), "Deque is empty."

									_lowerCamelCase					     = self._back
									_lowerCamelCase					     = self._back.prev_node  # set new back
									# drop the last node - python will deallocate memory automatically
									_lowerCamelCase					     = None

									self._len -= 1

									return topop.val

					def 	snake_case__					(			self      ):
									assert not self.is_empty(), "Deque is empty."

									_lowerCamelCase					     = self._front
									_lowerCamelCase					     = self._front.next_node  # set new front and drop the first node
									_lowerCamelCase					     = None

									self._len -= 1

									return topop.val

					def 	snake_case__					(			self      ):
									return self._front is None

					def __len__(			self      ):
									return self._len

					def __eq__(			self ,				lowerCamelCase__      ):

									if not isinstance(lowerCamelCase__ ,				lowerCamelCase__      ):
													return NotImplemented

									_lowerCamelCase					     = self._front
									_lowerCamelCase					     = other._front

									# if the length of the dequeues are not the same, they are not equal
									if len(self      ) != len(lowerCamelCase__      ):
													return False

									while me is not None and oth is not None:
													# compare every value
													if me.val != oth.val:
																	return False
													_lowerCamelCase					     = me.next_node
													_lowerCamelCase					     = oth.next_node

									return True

					def __iter__(			self      ):
									return Deque._Iterator(self._front      )





					def __repr__(			self      ):
									_lowerCamelCase					     = []
									_lowerCamelCase					     = self._front
									while aux is not None:
													# append the values in a list to display
													values_list.append(aux.val      )
													_lowerCamelCase					     = aux.next_node

									return F"""[{", ".join(repr(lowerCamelCase__      ) for val in values_list      )}]"""


if __name__ == "__main__":
			import doctest

			doctest.testmod()


'''simple docstring'''

from itertools import permutations







def __A  (    ):
     _UpperCAmelCase					:  Union[str, Any]         =    list(map("""""".join ,       permutations("""0123456789"""       )       )       )
     return result[99_9999]


if __name__ == "__main__":
   print(solution())


