#include using namespace std; using ll = long long; int main(){ int t; cin >> t; for (int _ = 0; _ < t; _++){ ll p1, q1, p2, q2; cin >> p1 >> q1 >> p2 >> q2; if (p1 * q2 < p2 * q1) swap(p1,p2), swap(q1,q2); ll p3 = (p1 + q1 - p1 - 1) / (q1 - p1); ll q3 = (q1 + q1 - p1 - 1) / (q1 - p1); ll g = gcd(p3,q3); p3 /= g, q3 /= g; cout << p3 << " " << q3 << endl; } }