Area of intersection of two circles
Submissions: 400   Accuracy:

4.78%

  Difficulty: Easy   Marks: 2

You will be given the coordinates of the centres and the radii of two circles. Your task is to find the area of their intersection.

Input:
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of one line. This line has six space separated integers denoting x1, y1, r1, x2, y2, r2 where (x1, y1) is the centre of the first circle and r1 is its radius and (x2, y2) is the centre of the second circle and r2 is its radius. 

Note: Use the value of Pi as 3.1415926535897932384


Output:

Corresponding to each test case, in a new line, print the greatest integer less than or equal to the area of intersection of the two circles. See floor function here.


Constraints:

1 ≤ T ≤ 100

-109x1, y1, x2, y2 ≤ 109       

1 ≤ r1, r2 ≤ 109


Example:

Input

3
0 0 4 6 0 4
0 0 5 11 0 5
0 0 10 9 0 1

 

Output

7
0
3

Explanation: 
For the first case, the area of intersection comes out to be around 7.25298806, the greatest integer less than or equal to this is 7.
In the second case, there is no area common to the two given circles, hence the answer is 0.

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Hemang Sarkar


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.