Minimum and maximum numbers
93% Success1182 Attempts30 Points1s Time Limit256MB Memory1024 KB Max Code

Consider the following infinite full BST (Binary Search Tree) as shown in the figure.
You are required to find what is the minimum and maximum number in the subtree of the given node (including the node).

Input format

  • The first line of input contains the number of test cases denoted by T.
  • The first line of each test case contains 1 integer N denoting a node in the tree.

Output format

Print two integers containing minimum and maximum number in the subtree of the given node (including the node).

Constraints

\(1 \leq T \leq 10\)

\(1 \leq N \leq 10^{10}\)

Examples
Input
4
8
1
10
12
Output
1 15
1 1
9 11
9 15
Explanation

-

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading Editor...
Results