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