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