#P1795. 无穷的序列

无穷的序列

Description

There is a sequence AA with infinitely many elements, $A_i=\overline{1\underbrace{000\dots0}_{i-1\text{ zeros}}}$. There is another infinite sequence BB, $B=\overline{\underbrace{A_1A_2A_3A_4\dots}_{\text{the }i\text{-th is }A_i}}$, where xy\overline{xy} denotes concatenating xx and yy, and similarly for more numbers.

Thus, the first several digits of the infinite sequence BB are: 110100100010000100000\texttt{110100100010000100000}\dots.

Please find the digit at the specified position in the infinite sequence BB.

Input Format

The first line contains a positive integer NN, the number of queries.

Each of the next NN lines contains a positive integer aia_i, where aia_i denotes a position in sequence BB.

Output Format

Output NN lines, each being 00 or 11, representing the digit at position aia_i in the sequence.

4
3
14
7
6 

0
0
1
0

Hint

For 100%100\% of the testdata, N1500000N \leq 1\,500\,000, ai109a_i \le 10^9.

Translated by ChatGPT 5