#include <iostream>
#include <cstdio>
using namespace std;
int gcd (int a,int b){
while (b != 0){
int temp = a % b;
a = b;
b = temp;
}
return a;
}
int mcm(int x,int y){
return x/gcd(x,y)*y; //最小公倍数=两数之积/最大公约数
}
int main(int argc, char *argv[])
{
//freopen("D:\\c - free\\hdu_1713\\input.txt","r",stdin);
int T;
cin>>T;
while (T--){
int x1,y1,x2,y2;
scanf("%d/%d",&x1,&y1);
scanf("%d/%d",&x2,&y2);
int t = gcd(x1,y1);
x1 /= t,y1 /= t;
t = gcd(x2,y2);
x2 /= t,y2 /= t;
if (gcd(y1,y2) == 1) cout<<mcm(x1,x2)<<endl;
else cout<<mcm(x1,x2)<<"/"<<gcd(y1,y2)<<endl;
//分数最大公倍数=两分子最小公倍数/两分母最大公约数
}
return 0;
}