#94Easy
n-th digit of a number
Time: 1 s · Memory: 256 MB
- Functions
Statement
Write a function DigitN(k, n) that returns the -th digit from the right of a natural number ( is the units digit). If has fewer than digits, it returns . Use it to answer queries.
Input format
The first line contains (). Each of the next lines contains and (, ).
Output format
lines: DigitN(k, n) for each query.
Examples
Input
3 12345 7 123987 4 10120 5
Output
-1 3 1
Input
2 5 1 5 2
Output
5 -1
Note
Integer-divide by times — the last digit is the one you need. If the number has become by then, there is no such digit. In the first example: has no 7th digit (), the 4th digit of is , the 5th digit of is .
