← Back to Problems
The Impossible Correlation
Easy standard Linear Algebra Probability & Statistics
Time limit: 2 s per test  ·  Memory: 256 MB

A desk holds three assets and has estimated two of the three pairwise correlations: corr(1, 2) = a and corr(1, 3) = b. The third, corr(2, 3), has not been estimated yet.

Not every value in [-1, 1] is possible for it. Output the exact range of values corr(2, 3) can take.

You are given q such pairs (a, b); answer each.

Input

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

Output

q lines. Line i contains two real numbers: the smallest and the largest feasible value of corr(2, 3) for pair i, each with absolute or relative error at most 1e-9.

Constraints

1 <= q <= 1000

-1 < a, b < 1

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 an absolute tolerance of 1e-09 or a relative tolerance of 1e-09 of the expected value.

Examples

input
3
0.9 0.9
0 0
-0.8 0.6
output
0.62 1.0
-1.0 1.0
-0.96 0.0
input
1
0.5 0.5
output
-0.5 1.0
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
Discussion
No comments yet. Kick off the discussion.