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