Under construction

Still being built. Things may change

Jack and Jill and Joe

Time limit3sMemory limit512 MB

Summary
Find integers a and b with 100 <= a, b <= N maximizing a^2 + b(b+a) subject to |a^2 - b(b+a)| <= 30.
Level

Medium7 of 10

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

Problem

Jill and Jack each buy one plot of land. Jill's plot is a square with side length aa. Jack's plot is a rectangle whose sides are bb and b+ab + a, so its longer side exceeds its shorter side by exactly the side length of Jill's square.

Their father Joe sets the following rules.

  • aa and bb are integers, measured in feet.
  • 100≤a≤N100 \le a \le N and 100≤b≤N100 \le b \le N. The longer side b+ab + a of Jack's plot is not limited by NN.
  • The square of the difference of the two areas is at most 900 square feet, that is (a2−b(b+a))2≤900(a^2 - b(b + a))^2 \le 900.
  • Among all pairs that satisfy the rules above, the sum of the two areas a2+b(b+a)a^2 + b(b + a) is as large as possible.

Find that pair (a,b)(a, b). The pair that maximizes the sum is always unique.

Input

The first line contains the number of test cases TT. Each of the next TT lines contains one integer NN.

Constraints

  • 1≤T≤120001 \le T \le 12000
  • 100<N<231100 < N < 2^{31}

Output

Print one line for each test case. If no pair satisfies the rules, print impossible. Otherwise print aa and bb separated by one space, where aa is the side length of Jill's square and bb is the shorter side of Jack's rectangle.

Examples1

  1. Example 1

    Input
    2
    333
    900
    
    Expected output
    322 199
    898 555