#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long q;
  cin >> q;
  while (q--) {
    long long l1, r1, l2, r2;
    cin >> l1 >> r1 >> l2 >> r2;
    if (r1 - l1 < r2 - l2) {
      cout << l1 << " ";
      if (r2 == l1) {
        cout << r2 - 1 << endl;
      } else {
        cout << r2 << endl;
      }
    } else {
      if (r1 == l2) {
        cout << r1 - 1 << " ";
      } else {
        cout << r1 << " ";
      }
      cout << l2 << endl;
    }
  }
  return 0;
}
