need help for my program

My program gives correct output (gcd and lcm) but codechef tells it’s wrong answer. Why? Can anyone tell me the error in my program?

#include<stdio.h>
int main()
{
int i,a,b,r,gcd,lcm,t,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d",&a,&b);
t=a*b;
while(b>0)
{
r=a%b;
a=b;
b=r;
}
gcd=a;
lcm=t/a;
printf("%d %d\n",gcd,lcm);
}
return 0;
}

Provide the link to the question!!

//