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