MoEngage has
decks. Each deck consists of cards, numbered from to . He draws out card from each deck randomly with each card having an equal probability of being drawn.
MoEngage drew cards numbered and from the decks and respectively. Now, he wonders what is the probability that he will end up with a funny hand after drawing the third card.
A funny hand is when 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 , you need to print the value . It can be shown that this value is an integer.
Input Format
- First line will contain , 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 and denoting the size of each deck, the card drawn from the first deck, and the card drawn from the second deck respectively.
Output Format
For each test case, output a single integer, denoting on a separate line.
Constraints
Sample Input 1
3
4 2 3
6 2 1
5 2 5
Sample Output 1
2
1
0
Explanation
Test case : Drawing the cards or will result in a funny hand. Hence, the probability will be . The value .
Test case : Drawing the card will result in a funny hand. Hence, the probability will be . The value .
Test case : No matter what card MoEngage draws, he will never end up with a funny hand.
No comments:
Post a Comment