Question
Flip Chain
Determine the final list C after all operations.
Kael starts with an empty list C and is given an array D of size M. He initializes j = 0 and performs M operations on C as follows:
- If j == M + 1, stop.
- Add Dj to the end of C and increment j by 1.
- Reverse the list C.
Determine the final list C after all operations.
Input
The first line of the input contains a single integer M.
The second line of the input contains M space-separated integers.
The second line of the input contains M space-separated integers.
Output
Print the sequence C after all the operations.
Example
Sample Input
4
1 2 3 4
Sample Output
4 2 1 3
Explanation
List at start = []
Add 1 in list and reverse. List = [1]
Add 2 in list and reverse. List = [2, 1]
Add 3 in list and reverse. List = [3, 1, 2]
Add 4 in list and reverse. List = [4, 2, 1, 3]
4
1 2 3 4
Sample Output
4 2 1 3
Explanation
List at start = []
Add 1 in list and reverse. List = [1]
Add 2 in list and reverse. List = [2, 1]
Add 3 in list and reverse. List = [3, 1, 2]
Add 4 in list and reverse. List = [4, 2, 1, 3]