1#include<stdio.h>
2
3
4long long gcd(long long a , long long b)
5{
6 if(a==0)
7 return b;
8
9 return gcd(b%a , a);
10
11}
12
13
14int main()
15{
16
17 long long t;
18 scanf("%lld",&t);
19
20 while(t--)
21 {
22 long long a,b,k;
23
24 scanf("%lld%lld",&a,&b);
25
26 k=gcd(a,b);
27
28 printf("%lld %lld\n",k,(a*b)/k);
29
30 }
31
32 return 0;
33}
34
1function gcd(a, b) {
2 let r;
3 while (r!=0) {
4 r = a % b;
5 a = b;
6 b = r
7 }
8 return a;
9}
10
11function lcm(a, b) {
12 return Math.abs(a*b) / gcd(a,b);
13}
14
15function solution(n, m) {
16 return [gcd(n,m), lcm(n,m)]
17}
18
19