The first line of the input consists of a single integer c (1 <= c <= 200), the number of test cases.
Then follow the test cases, each beginning with a single line consisting of an integer n (1 <= n <= 200), the number of cars you are to consider in this test case. The remainder of each test case consists of n lines, one line per car, starting with a single upper case letter ("A" or "B"), giving the direction in which the car is going. Then follow, on the same line, two integers t (0 <= t <= 100 000) and d (1 <= d <= 100 000), giving the arrival time at the beginning of the road and the minimum travel time, respectively, both in seconds.
Within a test case, the cars are given in order of increasing arrival time, and no two cars will arrive at the same time.