Jaime and his numbers

All submissions for this problem are available.
Jaime and his numbers
Jaime Lannister is an intelligent guy .He likes to play with numbers . He made an interesting sequence of numbers in which the first two numbers are 1 and 2 and the other numbers are generated according to following rule :
"If A[i] is the i^{th} (for i>2) element in the sequence then ' i ' occurs A[i] times in the sequence and A[1]=1 and A[2]=2" .
First few terms in sequence are {1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7...}. Note that 3 occurs 2 times in the sequence, (because A[3] = 2).
You have to find the n^{th} number in the sequence.
INPUT:
First line contains t, the number of test cases. Each of the next t lines contains a number n.
CONSTRAINTS:
 0 < n <= 10^{13}
 1<= t <100
OUTPUT:
For every case, print the n^{th} term of the sequence.
SAMPLE TEST CASES:
Input:
2 6 16
Output:
4 7
Author:  arvchamp 
Tags  arvchamp 
Date Added:  19032014 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, JAVA, GO 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 