#nt101. 最大公约数

最大公约数

Greatest Common Divisor and Least Common Multiple

Problem Description

Read TT; there are TT groups of data. Each group gives two numbers a,ba, b; output their greatest common divisor and least common multiple.

Input Format

The first line contains one number TT.

The following TT lines each contain two numbers a,ba, b.

Output Format

TT lines in total, each with two numbers: the greatest common divisor and the least common multiple, respectively.

Sample Input

2
1 2
100 150

Sample Output

1 2
50 300

Constraints

For 100%100\% of the data, it is guaranteed that 1≤T≤1041\leq T\leq 10^4, 1≤a,b≤1091\leq a, b\leq 10^9.

Hint

  • Compute gcd⁡(a,b)\gcd(a,b) with the Euclidean algorithm; then lcm⁡(a,b)=a⋅b/gcd⁡(a,b)\operatorname{lcm}(a,b) = a \cdot b / \gcd(a,b). Beware of overflow when multiplying aa and bb (use 64-bit integers).