Reverse the numbers

Given a stream of numbers in the input, you are asked to write a function that would print those numbers in reversed order without using any additional data structures like lists or arrays. The input stops as soon as the number entered is -1.
def rev():
    n = int(input())
    if n == -1:
        return
    ....

Input

The input contains a stream of numbers (0 ≤ ) each on a separate line. It’s guaranteed that the input contains no more than 1000 lines.

Output

The program should print the numbers in reversed order.

Examples

Input
Output
1 2 4 3 -1
3 4 2 1
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue