Nth digit in sequence
Easy Accuracy: 30.16% Submissions: 351 Points: 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 ≤ 105

Example:
Input:
3
186

190
5

Output:
9

1
5

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Output Window