134. Slow Snails

Problem Statement:
One day, your friend Ahmed wanted to challenge you with the hardest challenge ever, watching snails for so long time!

Ahmed has n snails. His snails are trained to walk on a 1 meter circle circumference, this circle is drawn on a table and all the snails walk only on the circumference of this circle (clockwise or anti-clockwise) with constant speed 1 meter per hour. When two snails meet both instantly change their directions and continue walking.

The challenge is to place the snails on the circle and choose their directions to achieve the following:
1- The minimum number (min_meetings) of meetings between the snails in h hours.
2- The maximum number (max_meetings) of meetings between the snails in h hours.

Each case should be handled independently, in other words, solve the problem for the first case, and then solve it again for the second case.

Since the snails are so slow, and the number of hours may be very big, you decided to write a program that calculates the required numbers.

Please note that the circle's circumference is always 1 meter, and all the snails have the same constant speed 1 meter per hour, and you can place each snail anywhere on the circle (there is infinite number of different places on the circle), but you can't place two or more snails in the same position.

Input Format:
Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 1000). Followed by T lines, each line represents a test case. Each test case consists of two integers n and h (0 < n < 1000) (0 < h < 1000) separated by a space, representing the number of snails and the number of hours.

Output Format:
For each test case print in a single line two numbers min_meetings and max_meetings separated by a single space.

Sample Input:
3 1 5 2 1 3 1

Sample Output:
0 0 0 2 0 4

Notes:
Here is an explanation of the second test case:

max_meeting = 2

min_meeting = 0

 Added by: feras_kassar Added at: 2014-02-28 18:58:49 UTC Time Limit: 3 seconds Partial score: No Source: Damascus University First Training Contest 2014