Digit Queries#12312

Digit Queries

1 second
256 megabytes
Medium

You're given an integer and integer ,you're asked to print the i_{th} digit of S=(\underbrace{999...99}_{n \text{ times}})^2 MUST use straight digit convolution , no shortcuts.

If no such digit i.e. i>|S| then print .

Input

The first line contains single integer (1 \le t \le 10^5) – the number of test cases.

The first line of each test case contains two integers (1 \le n \le 10^{18} ; 1 \le i \le 5 \cdot 10^{18}) – the integer and the required index.

Output

For each test case , The answer for MUST use straight digit convolution , no shortcuts it.

Examples

Example 1

Loading
Loading

Note

In the First , Second , Third and Fourth test cases we've 99^2=9801 :

  1. 1_{st} (from left to right) digit is .

  2. 3_{rd} (from left to right) digit is .

  3. 2_{nd} (from left to right) digit is .

  4. 4_{th} (from left to right) digit is .

Scoring

  1. Subtask ( points) : (i=1)

  2. Subtask ( points) : (n \le 9)

  3. Subtask ( points) : (1 \le \sum n \le 10^6)

  4. Subtask ( points) : No additional constraints.