P21419 [HackerEarth] Raj is fond of Table Tennis. He has a few friends who also play table tennis. Once as he walked past his college, he found 2 of his friends, Melvin and Rakesh playing.
普及
题目描述

Raj is fond of Table Tennis. He has a few friends who also play table tennis. Once as he walked past his college, he found 2 of his friends, Melvin and Rakesh playing.

Anyone who plays Table Tennis, knows that when player p1 and p2 play a game of TT, the general scoring scheme is of the form,"p1:p2" where p1 is the score of the player 1 and p2 is that of player 2. The game starts at 0:0. When player 1 scores a point, the score becomes p1+1:p2. If from p1:p2, player 2 had scored a point, the score would become p1:p2+1.The game ends when either of them reaches a score of atleast 11 and the difference in score of the 2 players is exactly 2. The players stop playing when the game ends.

As he walked past the scoreboard, he found the scores to be : "X1:Y1". Raj then decides to play a game too. So, he rushes to his room to put on some casual clothing and join the two. When he returns back, he found that the game had ended and the scores then were: X2:Y2.

Since both Melvin and Rakesh are equally good, the match could have gone on a few duece before ending.
We say the scores are at duece, when the score of the two players is greater than or equal to 10 and the difference in their score is 0 at that instant.

Now Melvin, being a big fan of maths, makes a condition that Raj can join them in playing TT, if he answers his question correctly. Melvin goes on to state his question.

"Going by the normal rules of TT, in how many possible ways, the score X1:Y1 could have been converted to X2:Y2?"

Two scoring ways are said to be different, if the scoreboard is different after any Kth point was scored in the match.
(Obviously, (x1+y1 ≤ K ≤ x2+y2))

Raj is desperate to get a game and he is in no mood to squeeze his brain to answer Melvin. So, he calls you to help him.

So, given the initial score X1:Y1 and the final score X2:Y2, print the number of ways in which the initial score could have been converted to the final score. Melvin is tricky, and so he may even give wrong scores. So, if X2:Y2 is not a valid final score, print -1.

A valid final score is one which is reachable from the initial score and at which the game has ended.

Input:
The first line contains an integer T, denoting the number of testcases to come.
Then each of the next T lines contain 4 integers: x1, y1, x2, y2 separated by spaces.
where (x1,y1) denotes the initial score and (x2,y2) denotes the final score.

Output:
For each Testcase 'i', print on a new line, Case i: x
where x is the number of ways to achieve the scoring OR "-1" if X2:Y2 is not a valid final score. (Quotes for clarity)
Since the value can be large, output it modulo 1000000009.

Constraints:
1 ≤ T ≤ 100
0 ≤ x1 ≤ x2 ≤ 30
0 ≤ y1 ≤ y2 ≤ 30

SAMPLE INPUT
2
6 9 11 9
10 11 14 12

SAMPLE OUTPUT
Case 1: 1
Case 2: 2

Explanation

In Case 1:
Player 2 didn't get any additional points. All the points after the initial scores were scored by player 1. There is only one possible way for that.

In Case 2:
From, 10:11, the score could not have gone to 10:12, because that would end the game. So, the next score should have been 11:11.From 11, 11, either p1 or p2 could have scored, leading to:
12 11 (or) 11 12.
If the score had been 11, 12, then the next 3 points were scored by p1. This gives us one way of reaching 14:12.
If the score had been 12 11, the next score should have been 12 12
** (Because, if the score had become 13:11, then the game would have ended)**
From 12:12, the next 2 points must have been scored by P1, leading to 14:12. This gives another way of reaching 14:12.
Thus the 2 ways are:
10:11 -> 11:11-> 12:11-> 12:12-> 13:12 ->14:12
10:11 -> 11:11-> 11:12-> 12:12-> 13:12-> 14:12

The two ways are different because the scoreboard is different when the 23rd point was scored in the match (12:11 and 11:12)
Thus the answer is 2.

输入格式

见题面

输出格式

见题面

样例输入
100 4 5 28 30 3 3 28 30 9 10 28 30 8 1 28 30 1 10 28 30 8 2 28 30 9 0 28 30 3 3 28 30 4 2 28 30 1 6 28 30 3 7 28 30 4 3 28 30 6 3 28 30 7 6 28 30 2 5 28 30 7 7 28 30 1 9 28 30 4 3 28 30 5 3 28 30 4 2 28 30 2 8 28 30 9 5 28 30 2 4 28 30 9 2 28 30 6 6 28 30 1 3 28 30 9 3 28 30 9 8 28 30 4 0 28 30 2 7 28 30 3 11 28 30 0 8 28 30 6 2 28 30 9 7 28 30 6 7 28 30 4 4 28 30 1 5 28 30 3 4 28 30 6 3 28 30 9 9 28 30 3 4 28 30 2 3 28 30 4 5 28 30 9 11 28 30 8 8 28 30 3 3 28 30 0 9 28 30 4 9 28 30 1 7 28 30 4 5 28 30 0 0 27 29 0 0 11 13 0 0 24 26 0 0 12 14 0 0 11 13 0 0 9 11 0 0 25 27 0 0 15 17 0 0 14 16 0 0 13 15 0 0 23 25 0 0 9 11 0 0 5 7 0 0 0 2 0 0 22 24 0 0 18 20 0 0 8 10 0 0 27 29 0 0 20 22 0 0 7 9 0 0 1 3 0 0 27 29 0 0 17 19 0 0 6 8 0 0 3 5 0 0 20 22 0 0 26 28 0 0 15 17 0 0 15 17 0 0 19 21 0 0 9 11 0 0 26 28 0 0 23 25 0 0 9 11 0 0 0 2 0 0 19 21 0 0 0 2 0 0 22 24 0 0 2 4 0 0 22 24 0 0 13 15 0 0 10 12 0 0 1 3 0 0 18 20 0 0 0 2 0 0 7 9 0 0 22 24 0 0 19 21 0 0 5 7 0 0 19 21
样例输出
Case 1: 16016 Case 2: 1032192 Case 3: 140 Case 4: 80 Case 5: 57344 Case 6: 10 Case 7: 121110528 Case 8: 373793253 Case 9: 8200192 Case 10: -1 Case 11: 2688 Case 12: 118272 Case 13: 183040 Case 14: 2928640 Case 15: 35840 Case 16: 35840 Case 17: 256 Case 18: 51480 Case 19: 73728 Case 20: 54912 Case 21: 448 Case 22: 7340032 Case 23: 147456 Case 24: 524288 Case 25: 1680 Case 26: 393609216 Case 27: 1025024 Case 28: 7040 Case 29: 2240 Case 30: -1 Case 31: 16128 Case 32: 878592 Case 33: 2050048 Case 34: 1802240 Case 35: 5760 Case 36: 1464320 Case 37: 1032192 Case 38: 65536 Case 39: 1025024 Case 40: -1 Case 41: 823680 Case 42: 128 Case 43: 13178880 Case 44: 449839104 Case 45: 98402304 Case 46: 172032 Case 47: 504 Case 48: 21504 Case 49: 30720 Case 50: -1 Case 51: 16128 Case 52: 16016 Case 53: 675840 Case 54: 739024 Case 55: 3584 Case 56: 9437184 Case 57: 105431040 Case 58: 168689664 Case 59: 1008 Case 60: -1 Case 61: 22880 Case 62: 3294720 Case 63: 344064 Case 64: 288 Case 65: 860160 Case 66: 449839104 Case 67: 1032192 Case 68: 126720 Case 69: 458752 Case 70: -1 Case 71: 2562560 Case 72: 32256 Case 73: 3840 Case 74: 2928640 Case 75: 5601024 Case 76: 64512 Case 77: 43008 Case 78: 3670016 Case 79: 540672 Case 80: -1 Case 81: 374865920 Case 82: 1344 Case 83: 64 Case 84: 229376 Case 85: 131203072 Case 86: 2928640 Case 87: 224 Case 88: 2621440 Case 89: 14336 Case 90: 196804608 Case 91: 86507520 Case 92: 2800512 Case 93: 31680 Case 94: 6720 Case 95: 102960 Case 96: 64 Case 97: 96 Case 98: 11520 Case 99: 48 Case 100: -1