Yellowstar likes integers so much that he listed all positive integers in ascending order,but he hates those numbers which can be written as a^b (a, b are positive integers,2<=b<=r),so he removed them all.Yellowstar calls the sequence that formed by the rest integers“Y sequence”.When r=3,The first few items of it are：
Given positive integers n and r，you should output Y(n)(the n-th number of Y sequence.It is obvious that Y(1)=2 whatever r is).
The first line of the input contains a single number T:the number of test cases.
Then T cases follow, each contains two positive integer n and r described above.
For each case,output Y(n).
2 10 2 10 3