Once upon a time, three girls|Winnie, Grace and Bonnie|owned a large number of pearls. However, each of them only had a single color of pearls. Winnie had white pearls, Grace had grey pearls and Bonnie had black pearls. One day, after a long discussion, they decided to make necklaces using the pearls. They are interested in knowing how many patterns can be formed using a certain number of pearls of each color, and have asked you to solve this problem for them. Note that rotating or ipping over a necklace cannot produce a different kind of necklace. i.e. The following gure shows three equivalent necklaces. The following gure shows all possible necklaces formed by 3 white pearls, 2 grey pearls and 1 black pearl.
Input The input begins with an integer N ( 2500) which indicates the number of test cases followed. Each of the following test cases consists of three non-negative integers a, b, c, where 3 a + b + c 40. Output For each test case, print out the number of different necklaces that formed by a white pearls, b grey pearls and c black pearls in a single line. Sample Input 2 3 2 1 2 2 2 Sample Output 6 11
运用组合数学的知识,根据a+b+c的奇偶性大力讨论。
