Minimum and maximum numbers

4.6

5 votes
Mathematics, Basic Math, Math
Problem

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

 

Sample Input
4
8
1
10
12
Sample Output
1 15
1 1
9 11
9 15
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

-

Editor Image

?