Queue

No attempts yetTime limit0.5sMemory limit256 MB

Problem

Implement a queue that stores integers, then process the commands given in the input in order.

There are six commands.

  • push X: put the integer XX into the queue.
  • pop: remove the integer at the front of the queue and print it. Print -1 if the queue is empty.
  • size: print how many integers the queue holds.
  • empty: print 1 if the queue is empty and 0 otherwise.
  • front: print the integer at the front of the queue. Print -1 if the queue is empty.
  • back: print the integer at the back of the queue. Print -1 if the queue is empty.

Input

The first line contains the number of commands NN (1N100001 \le N \le 10\,000).

Each of the next NN lines contains one command. Every integer given with push is at least 11 and at most 100000100\,000. No command outside the list above appears.

Output

For each command that prints something, print its result on its own line. If no command prints anything, print nothing.