Under construction

Still being built. Things may change

Consonants (Large)

Interview

Time limit5sMemory limit512 MB

Summary
Count the substrings of each given name that contain at least n consecutive consonants.
Level

Medium5 of 10

Topics
String, Combinatorics
Solved
No attempts yet

Problem

The English alphabet has 26 letters, and each of them is either a vowel or a consonant. In this problem a, e, i, o and u are vowels, and the other 21 letters are consonants.

A tribe living in the Greatest Colorful Jungle names its members with English letters. Picking a good name is not easy, because the name fixes the member's standing inside the tribe. The less common the name, the higher the standing.

The leader of the tribe works as a linguist. He noticed that uncommon names are hard to pronounce, and that they are hard to pronounce because they contain too many consecutive consonants. So he declared that a member's standing is given by the nn-value of the name, which is the number of substrings that contain at least nn consecutive consonants. For n=3n = 3 the name quartz has nn-value 4, because the substrings quartz, uartz, artz and rtz each contain at least 3 consecutive consonants. A larger nn-value means a higher standing. Two substrings count as different when they start or end at different positions, even when they spell the same letters. The name tsetse contains 11 substrings with 2 consecutive consonants, and among them the substring formed by the first three letters and the substring formed by the last three letters both spell tse, yet they are counted separately.

The leader assigns a name and a value of nn to every member. He has no trouble making the names meaningful, but he is bad at computing nn-values. Compute the nn-value of each name. Different names may come with different values of nn.

Input

The first line contains the number of test cases TT. Each of the next TT lines describes one test case: the name of a member, given as a string of LL lowercase English letters, then a space, then an integer nn.

Limits

  • 1≤T≤1001 \le T \le 100
  • 1≤L≤1061 \le L \le 10^6
  • 0<n≤L0 < n \le L
  • The whole input is at most 6 MB.

Output

For each test case, print one line in the form Case #x: y, where x is the test case number starting from 1 and y is the nn-value of that member's name.

Examples7

  1. Example 1

    Input
    4
    quartz 3
    straight 3
    gcj 2
    tsetse 2
    
    Expected output
    Case #1: 4
    Case #2: 11
    Case #3: 3
    Case #4: 11
    
  2. Example 2

    Input
    3
    a 1
    b 1
    z 1
    
    Expected output
    Case #1: 0
    Case #2: 1
    Case #3: 1
    
  3. Example 3

    Input
    2
    aeiou 1
    aeiouaeiouaeiou 2
    
    Expected output
    Case #1: 0
    Case #2: 0
    
  4. Example 4

    Input
    1
    bcdfghjklm 1
    
    Expected output
    Case #1: 55
    
  5. Example 5

    Input
    2
    bcdfg 5
    bcdfa 5
    
    Expected output
    Case #1: 1
    Case #2: 0
    
  6. Example 6

    Input
    4
    ab 1
    ba 1
    aba 2
    bab 2
    
    Expected output
    Case #1: 2
    Case #2: 2
    Case #3: 0
    Case #4: 0
    
  7. Example 7

    Input
    2
    sgbazrrapmhawvbavhgayvfabgwaghpafhlayltacmpabph 4
    sgbazrrapmhawvbavhgayvfabgwaghpafhlayltacmpabph 3
    
    Expected output
    Case #1: 0
    Case #2: 969