There are ‘p’ balls of type P, ‘q’ balls of type Q and ‘r’ balls of type R. Using the balls we want to create a straight line such that no two balls of same type are adjacent.
First line of input contains number of test cases T. Each line of test case contains number of balls of each type seperated by a single space.
Number of ways to arrange balls are displayed and 0 is displayed if there are no ways.
1 <= T <= 30
1 <= p,q,r <= 9
2 2 2
1 1 1
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.