#include <bits/stdc++.h>
using namespace std;
int q, l, r, l1, r1;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> q;
  while (q--) {
    cin >> l >> r >> l1 >> r1;
    if (r1 == l) r1--;
    cout << l << " " << r1 << endl;
  }
  return 0;
}
