Given two integers N and M you have to find out an integer which is a power of M and is nearest to N.
Note: If there are multiple ways to do this, print the greatest number possible.
First line of input contains of an integer 'T' denoting number of test cases . Then T test cases follow.
Only line of each test case contains two integers N and M.
for each case print an integer corresponding to the answer .
0 < M, N <= 10^9
1 <= T <= 500
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.