Andrew the Ant#4152

Andrew the Ant

1 second
128 megabytes
Hard

Andrew the Ant is fascinated by the behavior of his friends. Thousands of them are marching their paths on and on. They can build highly organized ant-hills. Sometimes, however, they act a little bit stupidly.

Recently, Andrew watched his fellow ants marching on top of a long piece of wood. He noticed their behavioral pattern is very simple: Each ant walks slowly forward with a constant speed of cm per second. Whenever it meets another ant, both of them only touch with their antennae and immediately turn around and walk the opposite direction. If an ant comes to the end of the wood, it falls down and does not affect other ants anymore.

prb4152-02

The picture above shows an example of moving ants in time s. In one second, the ants E and A meet at position and change their directions. The ant A then meets B in the next seconds. At the same time ( seconds after the start), the ants C and D will meet too. All four of them change their directions. In the next second (time s), the first ant (E) falls down off the left end, etc.

Your task is to simulate the movement of ants. For simplicity, suppose that the ants have zero size (although the picture could suggest something else).

Input

The input consists of several scenarios. Each scenario starts with a line containing two integer numbers and , separated by a space. is the length of the wood in cms (1 \leq l \leq 99999), and is the number of ants at the beginning of the simulation (1 \leq a \leq l + 1).

Then there are lines, each containing a positive integer x_i, one space, and an uppercase letter. The number (0 \leq x_i \leq l) specifies the position of the -th ant and the letter its initial direction: either "L" for left (towards zero) or "R" for right. No two ants will start at the same position.

Output

For each scenario, you should print a single line containing the text "The last ant will fall down in seconds - started at .", where is the exact time when the last ant (or two) reaches the end of the wood, and is the position where that particular ant has originally started in time . If two last ants fall down at the same time, print "started at and ", indicating both of their positions, p < q.

Examples

Example 1

Loading
Loading