#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int l1, r1, l2, r2;
  cin >> l1 >> r1 >> l2 >> r2;
  long long int a = (r1 + l1) / 2;
  long long int b = (r2 + l2) / 2;
  if (a == b) {
    cout << a << " " << b + 1 << '\n';
    ;
  } else {
    cout << a << " " << b << '\n';
    ;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
