Nth digit in sequence
Submissions: 336   Accuracy:

29.75%

  Difficulty: Easy   Marks: 2

You are given the sequence: 0123456789101112131415...

The 0th digit of this sequence is 0, the 1st digit of this sequence is 1, the 2nd digit of this sequence is 2 and so on.

You will be given some queries. Each query will ask you to print the digit at the ith position for some i.

Input:

The first line of the input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consist of one line which contains a positive integer i, which asks you to print the ith digit in the sequence given.

Output:

Corresponding to each test case, in a new line, print the digit at that position.

Constraints:

1 ≤ T ≤ 2000
1 ≤ Query Value ≤ 100000

Example:

Input
3
186

190
5

Output
9

1
5

** For More Input/Output Examples Use 'Expected Output' option **

Author: Hemang Sarkar


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.