After last lecture, you must know a lot of queue. Queue is a FIFO list. But do you know magic queue? Magic queue is a queue which supports four operations:
Push_frist x: push an element x from the front of the queue.
Pop_first: pop an element x from the queue.
Push_last x: push an element x at the rear of the queue.
Pop_last:pop an element x at the rear of the queue.
(See more in the samples)
Now there is a magic queue and n operations. Please write a program which can display the element in the queue after n operations.