Reverse a linked list

Given a linked list, you are asked to reverse it and print the resulting reversed linked list in the end.

Input

The input is handled automatically, you don’t need to do anything.

Output

The program should print the reversed linked list.

Examples

Input
Output
5 4 5 6 1 -4
-4 1 6 5 4
Β 

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