← Back to Problems
Fixed Point
Easy standard Numerical Methods
Time limit: 2 s per test  ·  Memory: 256 MB

For real parameters c and d, the equation

x = 1/2 + c (x^3 - sin(d x)) / (4 + x^2)

has a unique solution x* in [0, 1].

You are given q queries. For each, compute x*.

Input

The first line contains the integer q. Each of the next q lines contains c and d, each with at most 6 digits after the decimal point.

Output

q lines, line i containing x* for query i, with relative error at most 1e-9.

Constraints

1 <= q <= 1000

-1 <= c <= 1

0 <= d <= 2

Scoring

This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.

Numeric answers are accepted if they are within a relative tolerance of 1e-09 of the expected value.

Examples

input
3
0.0 0.0
1.0 1.0
-0.5 2.0
output
0.5
0.4200978288395543
0.5830665259477369
input
1
0.8 1.5
output
0.40330625119482577
Python 3.13 i Execution environment Isolated microVM · 1 vCPU · no internet access Time and memory limits are set per problem Available packages numpy 2.5.0scipy 1.18.0pandas 3.0.0scikit-learn 1.9.0statsmodels 0.15.0cvxpy 1.9.2