D. Gold paint optimization
time limit per test
10 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

See PDF statement in attachment.

Examples
Input
2 1
2 0 0
0 2 0
Output
0.50000000
0.50000000
Input
2 2
2 0 0
10 10 10
Output
1.00000000
1.00000000
Input
2 2
2 0 0
0 1 1
Output
0.98985430
1.01014568