Follow the Folding Dot 

Write a program that will keep track of the location of a dot on a piece of paper as it is being folded.

Input 

The input file will contain 4 different types of records.

Type 1
will contain two real numbers separated by one space. These are, respectively, the width and height of the paper.

Type 2
will contain two real numbers and a character, all separated by one space. These numbers represent the coordinates of the dot on the paper. The first number is the distance horizontally from the upper left hand corner. The second is the distance down from the upper left hand corner. The character will tell you which side of the paper the dot is on (T for top, B for bottom).

Type 3
will contain two unseparated uppercase characters. The first character will tell you which of the four sides of the paper you are about to use (T for top, B for bottom, L for left, R for right). The second character will tell you whether to fold the paper over the top or under the bottom ( O for over, U for under) e.g., TO, would mean you take the top of the paper and fold it over. Remember that the upper left hand corner is always 0, 0.

Type 4
will contain one uppercase 'S'. This will tell you to stop folding the paper.

Output 

The output will consist of which piece of paper you are working on, the beginning size of the paper, the beginning location of the dot, the size of the paper and the location of the dot when you have finished folding the paper. Format must be as shown in the sample output below. An absolut error of 10-6 is allowed.

Process 

This is best explained by an example. Look at the first sample input case:


Place a 5.0$\times$8.25 paper on the desk in front of you. Place a dot on the top surface at 3.25 units right of the top left corner and 8.00 units down from the top. Now, take the top edge of the paper and fold it over the top. The paper is now 5$\times$4.125 and the dot is on the top of page 2. The location of the new position of the dot is 3.875 units from the top and 3.25 units to the right. Use these new `coordinates' as the starting positions for the next set of folding instructions.

Now, take the left edge of the paper and fold it under the bottom. The paper is now 2.5$\times$4.125 and the dot is on the top of page 2. The location of the new position of the dot is 3.875 units from the top and 0.75 units to the left.

Sample Input 

5.0 8.25
3.25 8.00 T
TO
LU
S
1.0 2.0
.55 1.3 B
LO
S

Sample Output 

Paper number 1
Beginning paper dimensions 5.000000 X 8.250000
Dot is on TOP of page 1. Position: 3.250000 X 8.000000

After folding paper. Paper dimensions: 2.500000 X 4.125000
Dot is on TOP of page 2. Position 0.750000 X 3.875000

Paper number 2
Beginning paper dimensions 1.000000 X 2.000000
Dot is on BOTTOM of page 1. Position: 0.550000 X 1.300000

After folding paper. Paper dimensions: 0.500000 X 2.000000
Dot is on BOTTOM of page 2. Position 0.050000 X 1.300000


Other Notes:

1.
The dot will never be on the edge of the paper or a fold line.

2.
When folding the paper, pretend you are cutting the paper. In other words, don't be concerned about the thickness of the fold.

3.
All input characters will be in uppercase.



Miguel Revilla
2000-08-31