#include<iostream>
using namespace std;
int cmmdc(int x,int y)
{
int r;
while(y)
{
r=x%y;
x=y;
y=r;
}
return x;
}
int main()
{
int n,x,y,nr=0,i,j,p=1;
cin>>n;
for(i=0;i<n;i++)
{
nr=0;
cin>>x>>y;
p=x*y;
for(j=1;j<p;j++)
if(cmmdc(j,p)==1)
nr++;
cout<<"("<<x<<","<<y<<")"<<":"<<nr<<endl;
}
return 0;
}