CTBW - Color The Big Wall

There is a big wall beside Bangladesh University Of Business and Technology (BUBT). The student of CSE wants to color it with many colors. So the students of CSE want permission to color the wall from Dipu Sir. Dipu Sir not only gives permission, but also he maintains this:

The wall is L meter long. Every student can do any of the following two operations:

  1. He can color the wall from i to j meter by a color.
  2. Otherwise he can count the different numbers of color from i to j meter.

In this problem you have given length of wall number of student you have to do same task here.

Input

Input starts with an integer T (≤ 25), denoting the number of test cases.

Each test case contains two integers. The first integer means number of students N (2 <= N <= 100), and the second integer means the length of wall L (1 < L < 1000).

Next N lines contain work done by nth Student. Each line contain a word (color or report).

  1. If the word is color than you have a color (A <= Color <= Z), and index i and j.
  2. If the word is report than there is two integer i and j you have to report how many different color form i to j.

You can assume that at first the full wall is color A.

Output

For each case, print the case number and next lines print the reports.

Example

Input:
1
5 5
Color F 1 2
Color B 2 4
Report 1 4
Color C 4 5
Report 1 5

Output:
Case 1:
2
3

Problem Setter: Shipu Ahamed, Dept. of CSE
Bangladesh University of Business and Technology (BUBT)


Added by:Shipu Ahamed
Date:2013-06-29
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2018-07-08 13:26:37
Watch out for blanklines in input when solving with Python. Thanks Akash for testcases, the statement doesn't define ranges precisely enough. I've got AC using [L-1:R] slicing for every "operation L R" query.
2014-08-14 20:03:46 Akash
why am i getting a wrong ans?
edit: AC..was just not considering test case for not painting the wall any time..if the wall is not painted any time then acc to ques. colour should be 1 and not 0 bcoz wall has already been painted by A initially
Test case:
2
6 5
Report 1 3
Color F 1 2
Color B 3 4
Report 1 5
Color C 4 5
Report 1 5
6 5
Report 1 3
Color F 1 2
Color B 2 4
Report 1 4
Color C 4 5
Report 1 5
Output:
Case 1:
1
3
3
Case 2:
1
2
3
check your sol. against this test case guys

Last edit: 2013-06-29 19:13:42
2014-08-14 20:03:46 Surbhi Sinha
pls tell me why my program gives wrong ans ?? I have tried all my test cases
id=9574669 thanks
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.