#include
using namespace std;
int gcd(int a, int b);
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n;
cin >> n;
for (int i = 0; i < n; ++i)
{
int a, b, c, d;
scanf("%d/%d+%d/%d=", &a, &b, &c, &d);
int num = a * d + b * c;
int den = b * d;
int cur_gcd = gcd(num, den);
num /= cur_gcd;
den /= cur_gcd;
cout << num;<br> if(den != 1)
cout << '/' << den;<br> cout << endl;<br> }
fclose(stdin);
fclose(stdout);
return 0;
}
int gcd(int a, int b)
{
if(a == 0)
return b;
return gcd(b % a, a);
}