BETA

Difficulty Level: Basic

Submissions: 2982 Accuracy:

38.2%

Print the Kth Digit
     

Given two numbers a and b, find kth digit from right of a^b.

Input:

The first line of the input contains T denoting the number of test cases.Each of the next T lines contains three space separated positive integers denoting the value of a , b and k respectively.


Output:

For each test case, output the kth digit from right of a^b in new line.


Constraints:

1<=T<=100
1<=a , b <=15
1<=k<=|totaldigits in a^b|


Example:

Input:
2
3 3 1
5 2 2

Output:
7
2

** For More Input/Output Examples Use 'Expected Output' option **

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.