#include <bits/stdc++.h>
const int maxn = 1e5 + 10;
const int maxm = 1e5 + 10;
const int mod = 1e9 + 7;
const long long int INF = 1e18 + 100;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-8;
using namespace std;
int main() {
  long long int n;
  long long int a, b, c, d;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    if (c == a) c += 1;
    printf("%lld %lld\n", a, c);
  }
}
