402862: GYM100923 F Por Costel and the Alien Invasion
Description
Extraterrestrials are invading Earth! Happily, we have someone to protect us: the squealing hero of humanity, Por Costel the pig! He has a brilliant plan which employs tinfoil and a lot of staplers, but he also needs your help.
The alien invasion takes place in multiple steps. It is concentrated on a -kilometer long area (the kilometers are numbered through from left to right). The invasion consists of events of the following type:
1) An extraterrestrial ship enters the atmosphere and stops at distance from the ground, spanning from kilometer to kilometer (inclusive).
2) The last extraterrestrial ship that entered the atmosphere (from the ones that are still present) leaves.
All that Por Costel needs from you is to build him a radar. He needs the radar to tell him at certain points in time the height of the alien ship that is closest to the ground directly above kilometer .
InputThe input file invazia.in will contain on the first line integers () and (), the number of kilometers and the number of events respectively.
Next come lines that each describe an event:
- character 'I' followed by three integers () - a new ship appears
- character 'E' - the last ship disappears
- character 'R' - followed by an integer number () - a radar query
It is guaranteed that for any 'E' operation there exists at least one alien ship in the atmosphere.
OutputIn the output file invazia.out you should print lines which contain the answers for each of Por Costel's radar queries ( is equal to the number of radar queries). In the case that there is no ship above kilometer , you should print the message "GUITZZZ!" (without the quotes).
ExampleInput12 6Output
I 1 7 10
R 3
I 1 12 1
E
I 5 12 2
R 7
10
2