ASCDFIB - Ascending Fibonacci Numbers


John is trying to learn the Fibonacci sequence. This is what he has learned so far. The first two terms of the sequence are f(1) = 0 and f(2) = 1.  The next term f(n) is then calculated by adding the previous two terms f(n-1) and f(n-2). Therefore,

f(1) = 0

f(2) = 1

f(3) = f(2) + f(1) = 1 + 0 = 1

f(4) = f(3) + f(2) = 1 + 1 = 2

f(5) = f(4) + f(3) = 2 + 1 = 3

f(6) = f(5) + f(4) = 3 + 2 = 5

After calculating this for a while, John realized that the values are becoming too big. In order to keep the values small, John changed his algorithm. Instead of calculating f(n) = f(n-1)+f(n-2), he decided he will calculate f(n) = ( f(n-1)+f(n-2) ) % 10^5.

Now John wants to do some research on his new modified Fibonacci sequence. He will give you an integer A (A<=10^5) and an integer B (B<=10^6). You have to output all the terms from f(A) to f(A+B) in ascending order (non-decreasing order). But printing so many numbers is too much of a hassle. So, if there are more than 100 terms in the output, then only print the first 100.

Input

The first line contains an integer T (T<=100), which is the number of test cases.
Each test case contains two positive integers A and B as mentioned before.

Output

For each test case, print case number (Check sample output) and then print the terms from f(A)  to f(A+B) in ascending order (non-decreasing order). If there are more than 100 terms in the output, then only print the first 100.

Example

Input:
3
1 3
3 3
100 1

Output:
Case 1: 0 1 1 2
Case 2: 1 2 3 5
Case 3: 15075 69026

hide comments
Samiul: 2013-09-14 12:23:17

@Mitch Schwartz: Sorry for creating confusion. You are right. I made mistake with series and sequence ( I was unaware about the difference ). I updated the statement and changed series with sequence. I also added the test case you suggested. I hope this will make the statement more clear. I didn't change the starting position of the sequence since I want the sequence to be 1-indexed. Thank you for pointing out the flaws in the statement.

@Prateek chandan: I suggest you read the question again carefully. Specially the output section.

Mitch Schwartz: 2013-09-14 12:03:22

Maybe because you used the same letter to refer to both sequences? And because it's extremely common in this type of problem for reduction mod M to be a final step as in "Since the answer may be very large, please output it mod M" where all mathematical properties hold on the non-reduced values -- it's pretty rare to be comparing reduced values to each other, so familiarity may create a bias toward interpreting it that way. Note that on SPOJ some problem setters may not have the best handle on English or mathematical terms (e.g., you use the word "series" when it should be "sequence", and the most common convention by far is to set f(0)=0 and f(1)=1), so there's also a tendency to think about other things the author could have meant that are very close to what he wrote, especially in regard to common conventions, consciously or unconsciously.

And I'm surprised you think the case I mentioned is a spoiler. Isn't it trivial? You can censor it if you wish.

Edit: Thanks. :)

Last edit: 2013-09-14 12:42:10
Prateek chandan: 2013-09-14 12:03:22

EASY ONE :)

Last edit: 2013-09-14 17:26:44
Samiul: 2013-09-14 12:03:22

@Mitch Schwartz: In the statement it is said : "he decided he will calculate f(n) = ( f(n-1)+f(n-2) ) % 10^5". So why will anyone even consider their value without mod? The problem is already pretty easy, giving cases like "100 1" will just make things easier.

But if more people complain about ambiguity then I will update the statement.

Mitch Schwartz: 2013-09-14 12:03:22

You could make clearer that we are sorting the terms according to their value *after* reduction mod 10^5 by updating the description and/or adding a simple case like "100 1" (answer: "15075 69026").

Last edit: 2013-09-14 05:30:41

Added by:forthright48
Date:2013-09-13
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Editorial