#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int q;
  cin >> q;
  while (q--) {
    int l1, r1, l2, r2;
    cin >> l1 >> r1 >> l2 >> r2;
    for (int i = l1; i <= r1; i++) {
      bool ans = false;
      for (int j = l2; j <= r2; j++) {
        if (i != j) {
          cout << i << " " << j << endl;
          ans = true;
          break;
        }
      }
      if (ans) break;
    }
  }
  return 0;
}
