Under construction

Still being built. Things may change

Polynesiaglot (Large)

Interview

Time limit5sMemory limit512 MB

Summary
Count length-L words over C consonants and V vowels where every consonant is followed by a vowel, modulo 1e9+7.
Level

Easy3 of 10

Topics
Dynamic programming, Combinatorics
Solved
No attempts yet

Problem

Ursula likes building constructed languages. Today she started one inspired by real Polynesian languages. So far she has fixed two rules.

  • Every word is made of letters. A letter is either a consonant or a vowel.
  • A consonant inside a word must be immediately followed by a vowel.

For example, in a language where a is the only vowel and h is the only consonant, a, aa, aha, aaha, and haha are valid words, while h, ahh, ahah, and ahha are not. The rule blocks a consonant after a consonant, and it also blocks a word that ends in a consonant.

Ursula's new language has CC different consonants and VV different vowels. How many different valid words of length LL are there? The answer can get very large, so report it modulo the prime 109+710^9+7.

Input

The first line contains the number of test cases TT. Each of the next TT lines contains three integers CC, VV, and LL, separated by spaces.

Limits

  • 1≤T≤1001 \le T \le 100
  • 1≤C≤501 \le C \le 50
  • 1≤V≤501 \le V \le 50
  • 1≤L≤5001 \le L \le 500

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 1 and yy is the number of valid words of length LL, modulo 109+710^9+7.

Hint

In the first test case of the first example, suppose a is the only vowel and h is the only consonant. The valid words of length 4 are aaaa, aaha, ahaa, haaa, and haha, so there are five of them.

In the second test case of the same example, suppose the vowels are a and e and h is the only consonant. The valid words of length 2 are aa, ae, ea, ee, ha, and he, so there are six of them.

Examples3

  1. Example 1

    Input
    2
    1 1 4
    1 2 2
    
    Expected output
    Case #1: 5
    Case #2: 6
    
  2. Example 2

    Input
    4
    1 1 1
    50 50 1
    1 50 1
    50 1 1
    
    Expected output
    Case #1: 1
    Case #2: 50
    Case #3: 50
    Case #4: 1
    
  3. Example 3

    Input
    4
    1 1 2
    50 1 2
    1 50 2
    50 50 2
    
    Expected output
    Case #1: 2
    Case #2: 51
    Case #3: 2550
    Case #4: 5000