Given two numbers n and k, print Kth prime factor among all prime factors of n.
Note: if k > all the count of prime factor of n, then print -1.
The first line of input contains an integer denoting the no of test cases. Then T test cases follow. Each test case contains two space seperated integers n and k respectively.
For each test case ouput a simple line containing a single integer denoting kth prime factor of n.
1 <= T <= 100
0 <= N <= 104
1 <= K <= 50
Test Case 1: n=225 and k=2 , Prime factor of 225 are: 3,3,5,5 .Kth prime factor is 3
Test Case 2: n=81 and k=5 , Prime factor of 81 is 3,3,3,3 , since k is greater than all the count of prime
factor, hence we print -1
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.