Ritesh has found out a keyboard from his store room which is very unique. Unique because the keyboard contains only 10 keys (the numpad). In other words the keyboard has 10 keys, they are 1,2,3,4,5,6,7,8,9,0.
Sharat has got the task to type all the natural number from 1 to N, using this keyboard. But the keyboard is in damaged condition, means, after pressing M keys in total from the keyboard, the keyboard completely stops working.
Now you being his friend need to find out the greatest natural number he can type using the keyboard starting from 1. (You need to find the value of N).
The first line of input contains the integer T, where T is the number of test cases. Then T test cases follow. Each test case contains an integer M, where M is maximum number of keys he can press in the keyboard before its completely damaged.
In each test case print a single integer N,where N is the greatest natural number he can type using the keyboard starting from 1.
0 < T < 105
0 < M < 38890
(i)For the 1st test case M=5, he can type 1 2 3 4 5. Now after pressing 5 keys the keyboard is damaged.
(ii)For the 2nd test case M=10, he can type 1 2 3 4 5 6 7 8 9, he has pressed 9 keys and can press only 1 more key but the next natural number he needs to type is 10, which is 2 digit, so he cant type 10, thus the greatest natural number he can type starting from 1 is 9.
(iii)For the 3rd test case M=15, he can type 1 2 3 4 5 6 7 8 9 10 11 12, now he has pressed 15 keys and the keyboard is damaged. Thus the greatest natural number he can type starting from 1 is 12.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.