#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int l1, r1, l2, r2;
    cin >> l1 >> r1 >> l2 >> r2;
    cout << l1 << " ";
    for (int j = l2; j <= r2; ++j) {
      if (j != l1) {
        cout << j << endl;
        break;
      }
    }
  }
  return 0;
}
