Problem10295--CF EDU - Segment Tree P2 - Step 4 - C. Painter

10295: CF EDU - Segment Tree P2 - Step 4 - C. Painter

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

The Italian abstract artist F. Mandarino became interested in drawing one-dimensional black and white paintings. He is trying to find the best location and the number of black sections of the picture. To do this, he spends on the line white and black segments, and after each of these operations, he wants to know the number of black segments in the resulting picture and their total length.

Initially, the line is white. Your task is to write a program that after each of these operations outputs data in which the artist is interested.

Input

The first line of the input file contains the total number of drawn segments $(1≤n≤100,000)$. 

The next $n$ lines contain the description of operations. Each operation is described by a line of the form c x l, where $c$ — color of the segment (W for white segments, B for black), and the segment itself has the form $[x;x+l)$, and the coordinates of both ends — integers not exceeding in absolute value 500,000. The length is set to a positive integer.

Output

After performing each of the operations, it is necessary to output to the output file on a separate line the number of black segments in the picture and their total length, divided by one space.

Sample 1 Input

7
W 2 3
B 2 2
B 4 2
B 3 2
B 7 2
W 3 1
W 0 10

Sample 1 Output

0 0
1 2
1 4
1 4
2 6
3 5
0 0

HINT

CF EDU.

Source/Category