#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  unsigned long long z[500][4];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> z[i][0] >> z[i][1] >> z[i][2] >> z[i][3];
  }
  for (int i = 0; i < n - 1; i++) {
    cout << z[i][0] << " ";
    if (z[i][0] != z[i][2]) {
      cout << z[i][2];
      cout << endl;
    } else
      cout << z[i][3] << endl;
  }
  cout << z[n - 1][0] << " ";
  if (z[n - 1][0] != z[n - 1][2]) {
    cout << z[n - 1][2];
  } else
    cout << z[n - 1][3];
  return 0;
}
