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