Help me in solving FLOW016 problem

My issue

what’s wrong with my code as it’s been accepted initially but failing for hidden test cases.

My code

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

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T-- > 0) {
		    int A = sc.nextInt();
		    int B = sc.nextInt();
		    int min = Math.min(A,B);
		    int max = Math.max(A,B);
		    int temp = 0;
		    int rem = max%min;
		    while(rem > 0) {
		        temp = rem;
		        rem = min%rem;
		        min = temp;
		    }
		    int GCD = min;
		    int LCM = (A*B)/GCD;
		    System.out.println(GCD + " " + LCM);
		}
	}
}

Problem Link: FLOW016 Problem - CodeChef

@chanchal1316
use long to avoid integer overflow;