'''simple docstring'''






from multiprocessing import Lock, Pipe, Process

# lock used to ensure that two processes do not access a pipe at the same time
SCREAMING_SNAKE_CASE_	   =			Lock()






def  UpperCamelCase__					(					_lowercase    :				Tuple   ,    _lowercase    :				str   ,    _lowercase    :				List[str]   ,    _lowercase    :				Optional[Any]   ,    _lowercase    :				Tuple   ,    _lowercase    :				int   ,    _lowercase    :				str     )							->	List[Any]:
  global process_lock

  # we perform n swaps since after n swaps we know we are sorted
  # we *could* stop early if we are sorted already, but it takes as long to
  # find out we are sorted as it does to sort the list with this algorithm
  for i in range(0   ,    1_0     ):
    if (i + position) % 2 == 0 and r_send is not None:
      # send your value to your right neighbor
      process_lock.acquire()
      r_send[1].send(_lowercase     )
      process_lock.release()

      # receive your right neighbor's value
      process_lock.acquire()
      __UpperCAmelCase:					Optional[int]		= rr_cv[0].recv()
      process_lock.release()

      # take the lower value since you are on the left
      __UpperCAmelCase:					Optional[int]		= min(_lowercase   ,    _lowercase     )
    elif (i + position) % 2 != 0 and l_send is not None:
      # send your value to your left neighbor
      process_lock.acquire()
      l_send[1].send(_lowercase     )
      process_lock.release()

      # receive your left neighbor's value
      process_lock.acquire()
      __UpperCAmelCase:					List[Any]		= lr_cv[0].recv()
      process_lock.release()

      # take the higher value since you are on the right
      __UpperCAmelCase:					Optional[int]		= max(_lowercase   ,    _lowercase     )
    # after all swaps are performed, send the values back to main
  result_pipe[1].send(_lowercase     )






def  UpperCamelCase__					(					_lowercase    :				Dict     )							->	Any:
  __UpperCAmelCase:					Union[str, Any]		= []
  __UpperCAmelCase:					List[Any]		= []
  # initialize the list of pipes where the values will be retrieved
  for _ in arr:
    result_pipe.append(Pipe()     )
  # creates the processes
  # the first and last process only have one neighbor so they are made outside
  # of the loop
  __UpperCAmelCase:					Any		= Pipe()
  __UpperCAmelCase:					Tuple		= Pipe()
  process_array_.append(
      Process(
          target=_lowercase   ,    args=(0, arr[0], None, temp_rs, None, temp_rr, result_pipe[0])   ,    )     )
  __UpperCAmelCase:					Dict		= temp_rs
  __UpperCAmelCase:					Optional[int]		= temp_rr

  for i in range(1   ,    len(_lowercase     ) - 1     ):
    __UpperCAmelCase:					List[Any]		= Pipe()
    __UpperCAmelCase:					int		= Pipe()
    process_array_.append(
        Process(
            target=_lowercase   ,    args=(i, arr[i], temp_ls, temp_rs, temp_lr, temp_rr, result_pipe[i])   ,    )     )
    __UpperCAmelCase:					Dict		= temp_rs
    __UpperCAmelCase:					List[str]		= temp_rr

  process_array_.append(
      Process(
          target=_lowercase   ,    args=(
              len(_lowercase     ) - 1,
              arr[len(_lowercase     ) - 1],
              temp_ls,
              None,
              temp_lr,
              None,
              result_pipe[len(_lowercase     ) - 1],
          )   ,    )     )

  # start the processes
  for p in process_array_:
    p.start()

  # wait for the processes to end and write their values to the list
  for p in range(0   ,    len(_lowercase     )     ):
    __UpperCAmelCase:					List[Any]		= result_pipe[p][0].recv()
    process_array_[p].join()
  return arr






def  UpperCamelCase__					(					)							->	str:
  __UpperCAmelCase:					Any		= list(range(1_0   ,    0   ,    -1     )     )
  print("""Initial List"""     )
  print(*_lowercase     )
  __UpperCAmelCase:					List[Any]		= odd_even_transposition(_lowercase     )
  print("""Sorted List\n"""     )
  print(*_lowercase     )


if __name__ == "__main__":
    main()
'''simple docstring'''






def  UpperCamelCase__					(					_lowercase    :				List[str]     )							->	Union[str, Any]:
  __UpperCAmelCase:					int		= []
  __UpperCAmelCase:					List[Any]		= []
  __UpperCAmelCase:					List[Any]		= {
      """^""": 3,
      """*""": 2,
      """/""": 2,
      """%""": 2,
      """+""": 1,
      """-""": 1,
  }  # Priority of each operator
  __UpperCAmelCase:					int		= len(_lowercase     ) if (len(_lowercase     ) > 7) else 7

  # Print table header for output
  print(
      """Symbol""".center(8     )   ,    """Stack""".center(_lowercase     )   ,    """Postfix""".center(_lowercase     )   ,    sep=""" | """   ,    )
  print("""-""" * (print_width * 3 + 7)     )

  for x in infix:
    if x.isalpha() or x.isdigit():
      post_fix.append(_lowercase     )  # if x is Alphabet / Digit, add it to Postfix
    elif x == "(":
      stack.append(_lowercase     )  # if x is "(" push to Stack
    elif x == ")":  # if x is ")" pop stack until "(" is encountered
      while stack[-1] != "(":
        post_fix.append(stack.pop()     )  # Pop stack & add the content to Postfix
      stack.pop()
    else:
      if len(_lowercase     ) == 0:
        stack.append(_lowercase     )  # If stack is empty, push x to stack
      else:  # while priority of x is not > priority of element in the stack
        while len(_lowercase     ) > 0 and priority[x] <= priority[stack[-1]]:
          post_fix.append(stack.pop()     )  # pop stack & add to Postfix
        stack.append(_lowercase     )  # push x to stack

    print(
        x.center(8     )   ,    ("""""".join(_lowercase     )).ljust(_lowercase     )   ,    ("""""".join(_lowercase     )).ljust(_lowercase     )   ,    sep=""" | """   ,    )  # Output in tabular format

  while len(_lowercase     ) > 0:  # while stack is not empty
    post_fix.append(stack.pop()     )  # pop stack & add to Postfix
    print(
        """ """.center(8     )   ,    ("""""".join(_lowercase     )).ljust(_lowercase     )   ,    ("""""".join(_lowercase     )).ljust(_lowercase     )   ,    sep=""" | """   ,    )  # Output in tabular format

  return "".join(_lowercase     )  # return Postfix as str






def  UpperCamelCase__					(					_lowercase    :				str     )							->	Tuple:
  __UpperCAmelCase:					Union[str, Any]		= list(infix[::-1]     )  # reverse the infix equation

  for i in range(len(_lowercase     )     ):
    if infix[i] == "(":
      __UpperCAmelCase:					Tuple		= """)"""  # change "(" to ")"
    elif infix[i] == ")":
      __UpperCAmelCase:					Union[str, Any]		= """("""  # change ")" to "("

  return (infix_2_postfix("""""".join(_lowercase     )     ))[
      ::-1
  ]  # call infix_2_postfix on Infix, return reverse of Postfix


if __name__ == "__main__":
    SCREAMING_SNAKE_CASE_	   =			input('\nEnter an Infix Equation = ')  # Input an Infix equation
    SCREAMING_SNAKE_CASE_	   =			''.join(Infix.split())  # Remove spaces from the input
    print('\n\t', Infix, '(Infix) -> ', infix_2_prefix(Infix), '(Prefix)')