The Disc, being flat, has no real horizon. Any adventurous sailors who get funny ideas from staring at eggs and oranges for too long and set out for the antipodes soon learned that the reason distant ships sometimes looked as though they were disappearing over the edge of the world was that they were disappearing over the edge of the world. (Terry Pratchett — The Colour of Magic)
Not so long ago people used to believe that they lived on a 2-D world and that if they travelled far enough in one direction they would fall over the edge. Even when it was proved that the Earth is round, some of them were still afraid to travel to the southern hemisphere. Imagine instead a 1-D (linear) world. On such a world there are only two directions, left and right.
All inhabitants of this world are created at exactly the same moment, and at that instant every one of them starts to move — all with the same constant speed — either left or right. When two inhabitants meet, they politely exchange greetings, then each turns around and moves in the opposite direction. When an inhabitant reaches an end of the world, it falls off and disappears. Assume the time needed to greet and turn around is 0.
For a given creation scenario, determine which inhabitant is the last one to fall off, and at what time — counting from the moment of creation — it happens.
The input consists of several data sets, each describing one creation moment, with the following structure:
N
L V
DIR POS NAME
...
The first line gives the number of inhabitants N (N < 32000); a data set with N = 0 marks the end of the input. The second line gives the length of the world L (a positive real number) and the inhabitants' common speed V (a positive real number). The next N lines describe the inhabitants in order of increasing POS:
DIR — initial direction (p or P for positive/right, n or N for negative/left);POS — position at the moment of creation (0 ≤ POS ≤ L);NAME — the inhabitant's name (a string of up to 250 characters).Values on a line are separated by at least one space, and there are no empty lines. The input is always correct, and each data set has exactly one unique solution.
Print one line per data set. First print the time at which the last inhabitant falls off the world, counting from the moment of creation, truncated to two decimal places and right-justified in a field 13 characters wide. Then print a single space followed by the name of that inhabitant.