import java.util.*; import java.io.*; public class SixthGrade { Scanner in = new Scanner(System.in); int a; int b; public static void main(String[] args) { new SixthGrade().solve(); } public void solve() { //in = new Scanner("3\n5 10\n7 23\n42 56"); int num_cases = Integer.parseInt(in.nextLine()); for(int case_num = 1; case_num <= num_cases; case_num++) { String[] nums = in.nextLine().split(" "); a = Integer.parseInt(nums[0]); b = Integer.parseInt(nums[1]); int gcf = 1; for(int i=2; i<=a && i<=b; i++) { if((a%i == 0) && (b%i == 0)) { gcf = i; } } System.out.println(case_num + " " + a*b/gcf + " " + gcf); } } }