# [CODING] Funny Hand solution codechef

MoEngage has 33 decks. Each deck consists of NN cards, numbered from 11 to NN. He draws out 11 card from each deck randomly with each card having an equal probability of being drawn.

MoEngage drew cards numbered AA and BB from the decks 11 and 22 respectively. Now, he wonders what is the probability that he will end up with a funny hand after drawing the third card.

## [CODING] Funny Hand solution codechef

funny hand is when 33 consecutive numbered cards are present in your hand.
Help MoEngage calculate the probability of ending up with a funny hand after drawing the third card.

If the final probability of ending up with a funny hand is PP, you need to print the value P⋅NP⋅N. It can be shown that this value is an integer.

### [CODING] Funny Hand solution codechef

• First line will contain TT, the number of test cases. Then the test cases follow.
• Each test case contains a single line of input consisting of three space-separated integers N,A,N,A, and BB denoting the size of each deck, the card drawn from the first deck, and the card drawn from the second deck respectively.

### [CODING] Funny Hand solution codechef

For each test case, output a single integer, denoting P⋅NP⋅N on a separate line.

### Constraints

• 1≤T≤10001≤T≤1000
• 3≤N≤10003≤N≤1000
• 1≤A,B≤N1≤A,B≤N

## [CODING] Funny Hand solution codechef

``````3
4 2 3
6 2 1
5 2 5
``````

### Sample Output 1

``````2
1
0
``````

### [CODING] Funny Hand solution codechef

Test case 11: Drawing the cards 11 or 44 will result in a funny hand. Hence, the probability will be P=12P=12. The value P⋅N=12⋅4=2P⋅N=12⋅4=2.

Test case 22: Drawing the card 33 will result in a funny hand. Hence, the probability will be P=16P=16. The value P⋅N=16⋅6=1P⋅N=16⋅6=1.

Test case 33: No matter what card MoEngage draws, he will never end up with a funny hand.