


"""simple docstring"""
from queue import Queue
from typing import TYPE_CHECKING, Optional


if TYPE_CHECKING:
				from ..models.auto import AutoTokenizer





class        snake_case__       :





							'''simple docstring'''

							def 						lowerCAmelCase    (			self							: int						,    UpperCAmelCase_							: Any    )   ->Tuple:



														"""simple docstring"""



														raise NotImplementedError()



							def 						lowerCAmelCase    (			self							: Tuple    )   ->Optional[int]:



														"""simple docstring"""



														raise NotImplementedError()





class        snake_case__       (a__):





							'''simple docstring'''

							def __init__(			self							: Optional[int]						,    UpperCAmelCase_							: Optional[Any]						,    UpperCAmelCase_							: Optional[Any] = False						,    **UpperCAmelCase_							: Union[str, Any]    )   ->Tuple:



														"""simple docstring"""



														snake_case_          =						tokenizer
														snake_case_          =						skip_prompt
														snake_case_          =						decode_kwargs

														# variables used in the streaming process
														snake_case_          =						[]
														snake_case_          =						0
														snake_case_          =						True



							def 						lowerCAmelCase    (			self							: Optional[Any]						,    UpperCAmelCase_							: Optional[Any]    )   ->str:



														"""simple docstring"""



														if len(value.shape    ) > 1 and value.shape[0] > 1:
																					raise ValueError("""TextStreamer only supports batch size 1"""    )
														elif len(value.shape    ) > 1:
																					snake_case_          =						value[0]

														if self.skip_prompt and self.next_tokens_are_prompt:
																					snake_case_          =						False
																					return

														# Add the new token to the cache and decodes the entire thing.
														self.token_cache.extend(value.tolist()    )
														snake_case_          =						self.tokenizer.decode(self.token_cache						,    **self.decode_kwargs    )

														# After the symbol for a new line, we flush the cache.
														if text.endswith("""\n"""    ):
																					snake_case_          =						text[self.print_len :]
																					snake_case_          =						[]
																					snake_case_          =						0
														# If the last token is a CJK character, we print the characters.
														elif len(_lowerCamelCase    ) > 0 and self._is_chinese_char(ord(text[-1]    )    ):
																					snake_case_          =						text[self.print_len :]
																					self.print_len += len(_lowerCamelCase    )
														# Otherwise, prints until the last space char (simple heuristic to avoid printing incomplete words,
														# which may change with the subsequent token -- there are probably smarter ways to do this!)
														else:
																					snake_case_          =						text[self.print_len : text.rfind(""" """    ) + 1]
																					self.print_len += len(_lowerCamelCase    )

														self.on_finalized_text(_lowerCamelCase    )



							def 						lowerCAmelCase    (			self							: Optional[Any]    )   ->List[Any]:



														"""simple docstring"""



														if len(self.token_cache    ) > 0:
																					snake_case_          =						self.tokenizer.decode(self.token_cache						,    **self.decode_kwargs    )
																					snake_case_          =						text[self.print_len :]
																					snake_case_          =						[]
																					snake_case_          =						0
														else:
																					snake_case_          =						''''''

														snake_case_          =						True
														self.on_finalized_text(_lowerCamelCase						,    stream_end=_lowerCamelCase    )



							def 						lowerCAmelCase    (			self							: List[str]						,    UpperCAmelCase_							: int						,    UpperCAmelCase_							: Tuple = False    )   ->Tuple:



														"""simple docstring"""



														print(_lowerCamelCase						,    flush=_lowerCamelCase						,    end="""""" if not stream_end else None    )



							def 						lowerCAmelCase    (			self							: Union[str, Any]						,    UpperCAmelCase_							: List[Any]    )   ->int:



														"""simple docstring"""



														if (
														    (cp >= 0X4E00 and cp <= 0X9FFF)
														    or (cp >= 0X3400 and cp <= 0X4DBF)  #
														    or (cp >= 0X20000 and cp <= 0X2A6DF)  #
														    or (cp >= 0X2A700 and cp <= 0X2B73F)  #
														    or (cp >= 0X2B740 and cp <= 0X2B81F)  #
														    or (cp >= 0X2B820 and cp <= 0X2CEAF)  #
														    or (cp >= 0XF900 and cp <= 0XFAFF)
														    or (cp >= 0X2F800 and cp <= 0X2FA1F)  #
														):  #
																					return True

														return False





class        snake_case__       (a__):





							'''simple docstring'''

							def __init__(			self							: Any						,    UpperCAmelCase_							: Optional[int]						,    UpperCAmelCase_							: str = False						,    UpperCAmelCase_							: Union[str, Any] = None						,    **UpperCAmelCase_							: Any    )   ->Union[str, Any]:



														"""simple docstring"""



														super().__init__(_lowerCamelCase						,    _lowerCamelCase						,    **_lowerCamelCase    )
														snake_case_          =						Queue()
														snake_case_          =						None
														snake_case_          =						timeout



							def 						lowerCAmelCase    (			self							: int						,    UpperCAmelCase_							: List[Any]						,    UpperCAmelCase_							: int = False    )   ->str:



														"""simple docstring"""



														self.text_queue.put(_lowerCamelCase						,    timeout=self.timeout    )
														if stream_end:
																					self.text_queue.put(self.stop_signal						,    timeout=self.timeout    )



							def __iter__(			self							: int    )   ->Tuple:



														"""simple docstring"""



														return self



							def 						lowerCAmelCase    (			self							: int    )   ->Optional[Any]:



														"""simple docstring"""



														snake_case_          =						self.text_queue.get(timeout=self.timeout    )
														if value == self.stop_signal:
																					raise StopIteration()
														else:
																					return value







"""simple docstring"""
def   _a			( _SCREAMING_SNAKE_CASE			)      ->			list:

							if len(_SCREAMING_SNAKE_CASE			) <= 1:
														return [tuple(_SCREAMING_SNAKE_CASE			)]

							snake_case_          =						[]

							def generate(_SCREAMING_SNAKE_CASE			,	_SCREAMING_SNAKE_CASE			):
														if k == 1:
																					res.append(tuple(arr[:]			)			)
																					return

														generate(k - 1			,	_SCREAMING_SNAKE_CASE			)

														for i in range(k - 1			):
																					if k % 2 == 0:  # k is even
																												snake_case_    ,  snake_case_          =						arr[k - 1], arr[i]
																					else:  # k is odd
																												snake_case_    ,  snake_case_          =						arr[k - 1], arr[0]
																					generate(k - 1			,	_SCREAMING_SNAKE_CASE			)

							generate(len(_SCREAMING_SNAKE_CASE			)			,	_SCREAMING_SNAKE_CASE			)
							return res


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



