This page is still under construction.

Parts of this page are still being built. What you see may change.

Constructing a Square Root

Time limit1sMemory limit128 MB

Summary
For each N up to 1e9, find non-negative integers a and r with r^2 - a^2 = N and minimal a, or report IMPOSSIBLE.
Level

Medium6 of 10

Topics
Number theory, Math, Brute force
Solved
No attempts yet

Problem

A classic straightedge-and-compass construction uses only an unmarked straightedge and a compass. Because a compass is available, any integer multiple of the unit length (length 11) is easy to construct, and we can go further and construct the square root of any natural number.

For example, suppose we want to construct a segment of length 33\sqrt{33}. First pick a point XX on a horizontal line and construct a segment of length 44 that is perpendicular to the line and has XX as one endpoint. Call the other endpoint HH. Now draw a circle of radius 77 centered at HH; if YY is one of the points where this circle meets the horizontal line, then by the Pythagorean theorem the segment XYXY has length 72−42=33\sqrt{7^2 - 4^2} = \sqrt{33}.

Using this method we want to construct a segment of length N\sqrt{N}. That is, we must choose a non-negative integer segment length aa and a non-negative integer circle radius rr such that r2−a2=Nr^2 - a^2 = N. If several pairs (a,r)(a, r) work, use the one with the smallest segment length aa. (The segment length aa may be 00.)

Input

The first line contains the number of test cases TT. Each of the next TT lines contains one integer NN (1≤N≤1091 \le N \le 10^9).

Output

For each test case, print on one line two non-negative integers: the segment length aa and the circle radius rr, separated by a space. If several pairs (a,r)(a, r) satisfy the condition, print the one with the smallest segment length aa. If no such pair exists, print IMPOSSIBLE.

Examples1

  1. Example 1

    Input
    4
    33
    16
    50
    101
    
    Expected output
    4 7
    0 4
    IMPOSSIBLE
    50 51