You are given three non-negative integers N, M, and K. Your task is to print the Kth digit from the right in ‘N’ raised to the power ‘M’ that is, in N ^ M.
1) It is guaranteed that the Kth digit from the right always exists.
2) It is also guaranteed that 'K' is always less than or equal to the number of digits in N ^ M.
3) 'N' and 'M 'can’t be a 0 simultaneously.
The first line contains an integer ‘T', which denotes the number of test cases or queries to be run. Then, the T test cases follow.
The first line of each test case contains three non-negative integers N, M, and K, as described in the problem statement.
For each test case, print in a new line, an integer denoting the Kth digit in N^M from the right.
The output for each test case will be printed in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 100
0 <= N <= 15
0 <= M <= 15
1 <= K <= Digits in N ^ M
Time Limit: 1sec.
Sample Input 1:
2 4 1
Sample Output 1:
Explanation for sample input 1:
2 ^ 4 = 16, and the 1st digit in 16 from the right is 6.
Sample Input 2:
3 3 2
Sample Output 2:
Explanation for sample input 2:
3^3 = 27, and the 2nd digit in 27 from the right is 2.