Problems
10164 - Bird Lover
SUBMIT PROBLEM

Bird Lover

Time Limit: 1 sec

 

The Problem

Shawon is my little brother and he loves bird so much. So, he goes to the bird shop to buy some birds.

 

He wants to buy a bird and ask the shopkeeper what is the characteristic of the bird. The shopkeeper told him when the bird reach at age A then the bird give birth M child birds every year and when the bird reach at age D then the bird died. Same thing happen for the child bird also.

 

He bought N birds for breeding and those are the same type and each of those bird age one year. Now he is trying to calculate how many birds he has after Y years. After some time he realized that the calculation is so much difficult and he is not able to calculate the answer. Can you please help him to calculate the answer?

 

The Input

Input start with an integer number T which is test case (1 ≤ T ≤ 1000). Each test case contains two lines of input. First line contains 3 integers A (2 ≤ A ≤ 10), M (1 ≤ M ≤ 5) and D (A <  D ≤ 25) and second line contains 2 integers N (1 ≤ N ≤ 5) and Y (1 ≤ Y ≤ 25).

 

The Output

For each test case, print a single line “Case X: R”, where X is the case number start from 1 to T and R is total birds after Y years.

 

Sample Input

2

3 1 5

2 4

3 1 5

1 7

 

Sample Output

Case 1: 6

Case 2: 8

 

 

Intra University Programming Contest - Winter 2019 [BGC Trust University Bangladesh]

Problem Setter: Shahin ShamS