Input: 100) Denoting The Number of Test Cases
Input: 100) Denoting The Number of Test Cases
For example, in the above garden the main entrance is at A. So Sultan will start from A. When
Sultan is at A, he can choose either of the trails. Say he chooses the trail leading to E. Then he can
choose the trail to G or trail to F. Say he chooses F. Now he does not have any unvisited trail from F,
so he will go back to E. Now he must choose trail to G and then similarly will come back to E and back
to A. Then he will go towards B. Now he again has two choices. He can go to C or D, say he goes to
C, then he will be back to B, then will go to D, and hence back to B and also back to A thus finishing
his exercise. So after his exercise you will find: AEFFGGEBDDCCBA in his notepad. Can you find
the number of trails attached to the sprinklers just looking at the sequence written in the notepad?
Input
First line of the test file contains a positive integer T (T 100) denoting the number of test cases.
Hence follows T lines, each containing a valid sequence of sprinkler names. A sprinkler name will
always be capital Latin letter (A, B, . . . , Z). You may assume that there will be at least two sprinklers
in garden, otherwise there would have been no meaning of exercise right?
Output
For each case output the case number in the first line, followed by the number of trails for each sprinkler.
First print the sprinkler name followed by the count of trails. These lines should be in lexicographical
order of sprinkler name. Note that, you should not print about a sprinkler which is not present in the
garden. Look at the sample input output for more specific format of input output.
Sample Input
2
AEFFGGEBDDCCBA
ZAABBZ
Sample Output
Case 1
A = 2
B = 3
C = 1
D = 1
E = 3
F = 1
G = 1
Case 2
A = 1
B = 1
Z = 2