The code is executing but on submission its showing run time error. Can someone?

the question was for todays lunchtime.

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/* Name of the class has to be “Main” only if the class is public. /
class Codechef
{
public static void main (String[] args) throws IOException
{
// your code goes here
/
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();*/

    BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));

int t = Integer.parseInt(reader.readLine());

	for(int i=0;i<t;i++)
	{
	     int n = Integer.parseInt(reader.readLine());
	     int k = Integer.parseInt(reader.readLine());
	       for(int j=1;j<=n;j++)
	       {
	           k=k*j;
	    if(k%n==0)
	    {
	        System.out.println(j);
	        break;
	        
	    }
	    
	    
	    }
	}
}
}