Pizza Patrol


Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

The year is 2040. The Adelaide University Competitive Programming League (AUCPL) has taken over Australia, with over twenty million members. We are now using an advanced AI and computer vision system to detect people pushing into the queue for pizza.

People line up along a number line from 1 to 20,000,000 from the pizza counter. Every newcomer who cuts in front is shamed over a speaker. The closest person they've cut in front of is also announced so that they can be on the lookout for the sneaky line-cutter.

Once a greedy member pushes in, they stay at the new position as it would be too annoying to remove them. Thus, in the next checks, they count as a regular member.

Input

The first line consists of an integer n (1 \leq n \leq 10^5), the number of law-abiding members who are already in queue.

The second line consists of n space-separated integers, p_i\ (1 \leq p_i \leq 2\times 10^7), where each p_i represents the positions of each law abiding ACPC member.

The third line is an integer g (1 \leq g \leq 10^5), the number of greedy committee members that plan to cut into the queue. This is followed by g space-separated integers, g_i\ (1 \leq p_i \leq 2\times 10^7), where each g_i represents the positions of each greedy ACPC member.

Output

For each incoming greedy member pushing into position g with the closest member behind them at position p, print "A greedy member at g has pushed in front of the member at p, this is terrible" on a single line, in the order that the numbers appear in the input. If a greedy member is pushing into a position where in one is behind them, you don't need to print anything. Likewise, if a greedy members position is the same as someone already in queue, the greedy member gives up and leaves, so you don't need to print anything.

Hint: Due to standard library differences, you won't be able to reasonably pass this problem using Python. Try using C++.

Example

Input 1
4
1 4 6 8
6
0 2 4 5 10 9
Output 1
A greedy member at 0 has pushed in front of the member at 1, this is terrible
A greedy member at 2 has pushed in front of the member at 4, this is terrible
A greedy member at 5 has pushed in front of the member at 6, this is terrible
A greedy member at 9 has pushed in front of the member at 10, this is terrible

For the greedy member at position 0, the closest member they are pushing in front of is at position 1. Similarly, the greedy member at position 2 has the closest member behind them at position 4. The greedy member looking to push in at position 4 will give up and leave as there is already someone there. The greedy member at position 5 pushed in front of the member at position 6. And the greedy member at position 10 is not pushing in front of anyone, so there is no issue. Now there is a member at 10, so the greedy member at 9 is pushing in front of them


Comments

There are no comments at the moment.