#nt101. 最大公约数
最大公约数
Greatest Common Divisor and Least Common Multiple
Problem Description
Read ; there are groups of data. Each group gives two numbers ; output their greatest common divisor and least common multiple.
Input Format
The first line contains one number .
The following lines each contain two numbers .
Output Format
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 of the data, it is guaranteed that , .
Hint
- Compute with the Euclidean algorithm; then . Beware of overflow when multiplying and (use 64-bit integers).