Under construction

Still being built. Things may change

A Population of Rabbits

Interview

Time limit1sMemory limit256 MB

Summary
Count rabbit pairs alive in month M given lifespan D and breeding ages up to R, starting from one newborn pair.
Level

Easy3 of 10

Topics
Dynamic programming, Simulation
Solved
No attempts yet

Problem

A hypothetical population of rabbits follows fixed rules.

  1. In the first month the population is one pair of newborn rabbits.
  2. A pair can mate starting the month after it is born.
  3. Every pair that can mate does so, in every month.
  4. A pair that mates gives birth to one male and one female, a new pair, in the next month.
  5. A pair lives until the month its age reaches DD months, and it stops breeding once its age passes RR months, where R≤DR \le D.

An age is 1 month in the month a pair is born and grows by 1 each month. So a pair born in month bb is alive in months bb through b+D−1b + D - 1, and it mates in every month where its age is at least 2 and at most RR, that is in months b+1b + 1 through b+R−1b + R - 1.

Take D=3D = 3 and R=3R = 3. A pair lives three months and mates twice. The first pair is born in month 1, mates in month 2, and its first child pair is born in month 3. That same pair mates again in month 3, so a second child pair is born in month 4. The first pair dies in month 4, so it is not counted in the population of month 4.

Given DD, RR and MM, write a program that counts the rabbit pairs alive in month MM.

Input

The first line contains the number of test cases NN (1≤N≤1001 \le N \le 100). Each of the next NN lines contains three positive integers DD, RR, MM. Here DD is the age at which a pair dies, RR is the age after which a pair stops breeding, and MM is the month whose population you report. The bounds are D≤100D \le 100, R≤100R \le 100, M≤20M \le 20 and R≤DR \le D.

Output

For each test case print one line of the form Case #n: k, where nn is the test case number starting at 1 and kk is the number of rabbit pairs alive in month MM.

Examples2

  1. Example 1

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

    Input
    3
    3 2 6
    3 1 6
    100 100 20
    
    Expected output
    Case #1: 1
    Case #2: 0
    Case #3: 6765