Spiral
题号:NC237405
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

You like to wander about, but you hate to reach any position more than once. Therefore, you develop a routine to follow to prevent that.

You will walk along a -sided spiral. Starting from , he will walk straightly to , and then turn left for , and then walk ahead  more unit, and then again turn left for . After passing  straight lines, you will repeat the process above but walk for  units for each line. After passing  lines, you will walk for  units for each line and so on.
Now given how many units you pass, you need to find out where you are. The figure below shows a -sided spiral.

输入描述:

The first line contains an integer  (, the number of queries.

Then  lines follow, each line contains two integers  , denoting you walks for  units on -sided spiral.

输出描述:

Find your final position  for each query. For convenience, You only need to output  for each query. Your answer will be considered correct if the absolute or relative error doesn't exceed .
示例1

输入

复制
3
10 3
10 4
10 5

输出

复制
1.633974596216
2.000000000000
-1.902113032590

说明

In these three examples, your final positions are  and  respectively.