Bitaro's room is an isosceles right-angled triangle whose leg has length . A point in Bitaro's room is represented as the coordinate with , , . The vertex of the right angle is the origin. The two legs of the triangle are the -axis and the -axis.
One day, Bitaro noticed that his room is full of dust. In the beginning, there are dusts in the room. The -th dust lies in the point . More than one dust may lie at the same point.
Now, Bitaro is planning to sweep the room using brooms. We consider a broom as a segment in the room and we call the length of the segment its width. Since Bitaro is well-organized, he can use a broom only in the following two ways.
- Bitaro puts the broom in the room so that one of its corners lies at the origin, and the broom is parallel to the -axis. Then, he moves the broom horizontally to the positive direction of the -axis as much as possible, keeping it parallel to the y-axis and one of its corners lying on the -axis. If the broom has width , a dust lying in with and will be moved to (There may exist other dusts at ). This is called the procedure .
- Bitaro puts the broom in the room so that one of its corners lies at the origin, and the broom is parallel to the -axis. Then, he moves the broom vertically to the positive direction of the -axis as much as possible, keeping it parallel to the -axis and one of its corners lying on the -axis. If the broom has width , a dust lying in with and will be moved to (There may exist other dusts at ). This is called the procedure .
In Bitaro's room, events will happen sequentially. The event is one of the following.
- Bitaro calculates the coordinates of the dust .
- Bitaro uses a broom with width and performs the procedure .
- Bitaro uses a broom with width and performs the procedure .
- A new dust is added at the point . If there are dusts before this event, the new dust is the -th dust in the room.
Write a program which, given the length of the legs of the room, the coordinates of the dusts in the room, and the details of the events, calculates the coordinates of the dusts.
Input Specification
Two or three space separated integers are written in each ( ) . Let be the first integer. Then the meaning of this line is as follows.
- If , two integers , are written in this line. This means, in the event , Bitaro calculates the coordinates of the dust .
- If , two integers , are written in this line. This means, in the event , Bitaro uses a broom with width and performs the procedure .
- If , two integers , are written in this line. This means, in the event , Bitaro uses a broom with width and performs the procedure .
- If , three integers , , are written in this line. This means, in the event , a new dust is added at the point .
Output Specification
For each event with , write one line to the standard output. Output the -coordinate and the -coordinate of the dust when the event happens.
Constraints
.
.
.
.
.
.
.
.
.
.
.
There exists at least one event with .
Subtasks
- (1 point) , .
- (10 points) .
- (11 points) , , .
- (53 points) .
- (25 points) No additional constraints.
Sample Input 1
6 2 10
1 1
4 0
4 2 3
3 3
1 1
4 1 2
2 3
2 0
1 4
3 2
1 3
1 2
Sample Output 1
1 3
3 2
3 3
6 0
Explanation for Sample 1
- In the beginning, the 1st dust lies at , and the 2nd dust lies at . Figure 1 describes the room.
- In the event 1, the 3rd dust is added at the point . Figure 2 describes the room.
- In the event 2, Bitaro uses a broom with width 3 and performs the procedure . Then, the 1st dust is moved to . Figure 3 describes the room.
- In the event 3, Bitaro calculates the coordinates of the 1st dust.
- In the event 4, the 4th dust is added at the point . Figure 4 describes the room.
- In the event 5, Bitaro uses a broom with width 3 and performs the procedure . Then, the 1st dust is moved to , the 3rd dust is moved to , and the 4th dust is moved to . Figure 5 describes the room.
- In the event 6, Bitaro uses a broom with width and performs the procedure . Then, the 2nd dust is moved to . Figure 6 describes the room.
- In the event 7, Bitaro calculates the coordinates of the 4th dust.
- In the event 8, Bitaro uses a broom with width 2 and performs the procedure . No dust is moved. Figure 7 describes the room.
- In the event 9, Bitaro calculates the coordinates of the 3rd dust.
- In the event 10, Bitaro calculates the coordinates of the 2nd dust.
This sample input satisfies the constraints of Subtasks 1 and 5.
Sample Input 2
9 4 8
2 3
3 1
1 6
4 3
2 6
1 3
2 2
1 4
2 3
1 2
2 4
1 1
Sample Output 2
3 6
4 3
7 1
6 3
Explanation for Sample 2
This sample input satisfies the constraints of Subtasks 1, 2, 4, and 5.
Sample Input 3
8 1 8
1 5
4 4 1
2 6
1 2
2 3
4 2 2
2 5
1 1
1 3
Sample Output 3
4 1
3 5
3 2
Explanation for Sample 3
This sample input satisfies the constraints of Subtasks 1, 2, and 5.
Sample Input 4
7 4 9
1 5
2 2
4 2
5 0
2 6
2 3
1 2
3 6
1 4
3 1
1 1
2 2
1 3
Sample Output 4
4 2
5 1
1 6
5 2
Explanation for Sample 4
This sample input satisfies the constraints of Subtasks 1, 3, 4, and 5.
Comments