Implement different operations on a queue q .
The first line of input contains an integer T denoting the no of test cases . Then T test cases follow. The first line of input contains an integer Q denoting the no of queries . Then in the next line are Q space separated queries .
A query can be of four types
1. a x (Pushes an element x at the end of the queue q )
2. r (if queue is not empty pops the front element and prints it, else prints -1)
3. s (prints the size of the queue)
4. p (if queue is not empty prints the front element of the queue, else prints -1)
The output for each test case will be space separated integers denoting the results of each query .
a 5 a 10 a 15 r p
a 5 r p s
5 -1 0
In test case 1: In first query 5 is added to the queue.In second query 10 is added to the queue. In third query 15 is added to the queue. In fourth query 5 is removed from the queue and printed.In last query front element of the queue is printed i.e. 10.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.