#P1895. 数字序列

数字序列

Description

Define the function tostring(n)\mathrm{tostring}(n) as writing the number nn in base 1010 as a string. For example, tostring(12345)=12345\mathrm{tostring}(12345)={\tt 12345}. Based on this,

  • Define the string Sn=1+2+3+4++tostring(n)S_n={\tt 1+2+3+4+\cdots}+\mathrm{tostring}(n).
  • Define the string S=S1+S2+S3+S4+S_{\infty}=S_1+S_2+S_3+S_4+\cdots.

For example, the beginning of SS_{\infty} is:

$$\tt 112123123412345123456123456712345678123456789123456789101234567891011\cdots$$

Now, for a given ii, determine the character at position ii of SS_{\infty}.

Input Format

The first line contains a positive integer t (1t10)t\ (1 \le t \le 10), the number of testcases.

The next tt lines each contain one positive integer i (1i2311)i\ (1 \le i \le 2^{31}-1), representing a query.

Output Format

For each ii, output the digit at the corresponding position.

2
3
8

2
2

Hint

Translated by ChatGPT 5