Separated reversal with stacks

Use stacks to reverse sequences of integer numbers. Print first the even numbers in reverse order, and afterwards the odd numbers in reverse order.

Input

Input consists of several sequences of integer numbers, one per line.

Output

For every line, print the even numbers in reverse order, followed by the odd numbers in reverse order, all them separated by spaces.

Observation

To solve this exercise, the only containers that you should use are stacks.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:07:02.088Z

© Jutge.org, 2006–2026.
https://jutge.org