A Double Ended Queue is a data structure in which it is possible to insert and delete from both ends (front and rear). Given an integer m, size of double ended queue, and n operations, implement the double ended queue. Queries are defined as below.
Input:
First line in the input is an integer m, size of the queue. Second line of the input is an integer n total number of queries. Followed by n queries of the above mentioned format.
Output:
If an insertion operation can not be performed print "Queue overflow".
If a deletion operation can not be performed print "Queue underflow".
Separate each output with a newline. In the end print the queue elements separated by spaces (from rear to front).
Constraints:
All the elements are well with in the integer range.