Tanjiro and his sister Nezuko live in a village that is shaped like a circle with a radius R. There's also a crazy boy Zenitsu who loves Nezuko but he is so annoying that Tanjiro doesn't want him anywhere near his sister Nezuko, the cutest of all. So, he gives punishment to Zenitsu.
Zenitsu must start running from a point on the circle boundary to some inward direction. He runs in a straight line. Whenever he reaches a point on the boundary of the circle (say such a point is A), his direction is reflected with respect to the line connecting A and the centre of the circle. And he starts running again. He only stops running when he reaches the point from which he started running initially.
Tanjiro wants Zenitsu to run in such a way that before he stops running, his direction is reflected exactly N times. Besides, Tanjiro wants Zenitsu to get as much tired as it's possible. So, Zenitsu has to choose the longest possible route where his direction reflects exactly N times before he stops running.
While running, Zenitsu keeps screaming "Ne-Zu-Ko chaaaaaaaaaaan" on top of his voice to express his love.
Can you help Zenitsu determine how much distance he has to cover?
There will be several test cases.
In the first line, there will be an integer T (1 ≤ T ≤ 104), the number of test cases.
Each of the next T lines will contain two integers N (1 ≤ N ≤ 2 * 105) and R (1 ≤ R ≤ 103), the number of times Zenitsu's direction will reflect and the radius of the village, respectively.
For each test case, output the distance of the longest route Zenitsu can take. The output should be rounded to 4 digits after the decimal.
2 1 1 2 4
Login to submit