Problem: The only difference between the easy and the hard versions is the maximum value of .
You are given an infinite sequence of form "112123123412345" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from to , the second one — from to , the third one — from to , , the -th block consists of all numbers from to .
So the first elements of the sequence are "11212312341234512345612345671234567812345678912345678910". Elements of the sequence are numbered from one. For example, the -st element of the sequence is , the -rd element of the sequence is , the -th element of the sequence is , the -th element is , the -th element of the sequence is .
Your task is to answer independent queries. In the -th query you are given one integer . Calculate the digit at the position of the sequence.
Input Format: The first line of the input contains one integer () — the number of queries.
The -th of the following lines contains one integer — the description of the corresponding query.
Output Format: Print lines. In the -th line print one digit — the answer to the query , i.e. should be equal to the element at the position of the sequence.
Note: Answers on queries from the first example are described in the problem statement.