#include <bits/stdc++.h>
using namespace std;
int n;
pair<pair<int, int>, pair<int, int>> a[543];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first.first >> a[i].first.second >> a[i].second.first >>
        a[i].second.second;
  }
  for (int i = 0; i < n; i++) {
    if (a[i].first.first > a[i].second.first &&
        a[i].first.second > a[i].second.second) {
      cout << a[i].first.first << ' ' << a[i].second.first << endl;
    } else if (a[i].first.first >= a[i].second.second) {
      cout << a[i].second.first << ' ' << a[i].second.first + 1 << endl;
    } else if (a[i].first.first < a[i].second.first) {
      cout << a[i].first.first << ' ' << a[i].second.first << endl;
    } else {
      cout << a[i].first.first << ' ' << a[i].first.first + 1 << endl;
    }
  }
}
