Area of an amazing figure

All submissions for this problem are available.
There is an equilateral triangle ABC with side length 2*a. The coordinates of the triangle's vertices are A = (a, 0), B = (a, 0) and C = (0, sqrt(3) * a). Next, there are three circles with centers at the midpoints of sides AB, BC and AC respectively and radii r_{1}, r_{2} and r_{3} respectively. Compute the area of the intersection of the triangle and the three circles.
Input
 The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
 The first and only line of each test case contains four spaceseparated integers a, r_{1}, r_{2}, r_{3}.
Output
For each test case, print a single line containing one real number corresponding to the area of the intersection. Your answer will be considered correct if it has an absolute or relative error ≤ 5 * 10^{2}.
Constraints
 1 ≤ T ≤ 20
 1 ≤ a ≤ 50
 1 ≤ r_{1}, r_{2}, r_{3} ≤ 200
Example
Input 5 10 5 5 5 10 6 6 7 10 12 13 14 10 15 15 15 10 19 20 18 Output 0.0000000 1.417303000 138.1789 163.712 173.2064190
Explanation
Example case 2: The black colored area shown in the figure is the intersection between the triangle and the three circles.
Author:  admin2 
Editorial  https://discuss.codechef.com/problems/AREAFIGR 
Tags  acm17chn, admin2, chn17rol, geometry, medium, montecarlo 
Date Added:  25112017 
Time Limit:  5 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 