#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int res1[n];
  int res2[n];
  for (int i = 0; i < n; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a == d && a <= b) {
      a++;
    }
    while (d == a && d >= c) {
      d--;
    }
    res1[i] = a;
    res2[i] = d;
  }
  for (int i = 0; i < n; i++) {
    cout << res1[i] << " " << res2[i] << endl;
  }
  return 0;
}
