Common divisors and multiples

Time limit: 1s
Memory limit: 32MB


You are given tt pairs of positive integers. Find for each pair the greatest common divisor (gcd) and the least common multiple (lcm).

We define the greatest common divisor (gcd) of a pair (a,b)(a, b) as the largest integer that is a divisor of both aa and bb. We will note this as x=(a,b)x = (a, b).

We define the least common multiple (lcm) of a pair (a,b)(a, b) as the smallest integer that is a multiple of both aa and bb. We will note this as x=[a,b]x = [a, b].

Input data

The first line of the input will contain tt, the number of test cases. The following tt lines will contain the two values from each pair, aa and bb.

Output data

Each of the tt lines will have two numbers, representing the gcd and the lcm of the two numbers.

Constraints and clarifications

  • 1t1051 \leq t \leq 10^5
  • 1a,b1091 \leq a, b \leq 10^9
  • For tests worth 4040 points, 1a,b1051 \leq a, b \leq 10^5.



14 8
55 33
63 94
39 27
24 54


2 56
11 165
1 5922
3 351
6 216


(14,8)=2(14, 8) = 2, [14,8]=56[14, 8] = 56, etc.

Problem info

ID: 1983

Editor: stefdasca


Log in or sign up to be able to send submissions!