#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1 * 1e6 + 10);
int fen[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b, c, l1, l2, r1, r2, t, i;
  cin >> t;
  while (t--) {
    cin >> l1 >> r1 >> l2 >> r2;
    a = l1;
    b = l2;
    cout << l1 << " ";
    for (i = l2; i <= r2; i++) {
      b = i;
      if (a != b) {
        cout << b << endl;
        break;
      }
    }
  }
  return 0;
}
