9452 - Queueing   

Description

You need to write a program to simulate a queue of names. Each name is a string consisting of English letters only. There are three operations:

1. “Push [name]”, which means to enque name in the queue.

2. “Pop”, which means to deque. If the queue is empty, this operation takes no effect.

3. “Front”, which means to print out the name in the front of queue. If the queue is empty, print "empty" (without quotes).

Input

There will be at most 10^4 names in the queue at a time. However, the number of operations may be much more than that. Each line contains one of the following operations. “Push [name]” (without quotes), “Pop” (without quotes), “Front”(without quotes). The length of each name is at most 10.

Case 1: 0 < #operations < 200

Case 2: 0 < #operations < 20000

Case 3: 0 < #operations < 200000

Case 4: 0 < #operations < 1000000

Output

For each “Front” operation, print out the name in the front of the queue. 

Hint: circular queue (You are not able to use too much memory!)

Sample Input  Download

Sample Output  Download

Tags




Discuss