Kth Smallest Factor
Submissions: 5021   Accuracy:


  Difficulty: Medium   Marks: 4

You will be given two positive integers N and K. You have to find the Kth smallest factor of N. A factor of N is a positive integer which divides N.

Input : 
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two space separated positive integers which denote N and K.

Output : 
For each test case in a new line print the Kth smallest factor of N if it exists otherwise print -1.

1 ≤ T ≤ 100
1 ≤ N ≤ 1015
1 ≤ K ≤ 1011

Example : 
Input : 

4 2

4 3
10 1

Output :

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

Author: Hemang Sarkar

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.

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

to report an issue on this page.