1 #include<iostream> 2 3 using namespace std; 4 5 int gcd(int a, int b) 6 { 7 return b?gcd(b, a%b):a; 8 } 9 10 int main() 11 { 12 int a, b, c, d, m, k; 13 int n; 14 cin >> n; 15 while(n--) 16 { 17 cin >> a >> b >> c >> d; 18 int t=gcd(b,d); 19 m=a*d/t+b*c/t; 20 k=gcd(m, b*d/t); 21 cout << m/k << " " << b*d/t/k << endl; 22 } 23 return 0; 24 }