#include <bits/stdc++.h>
using namespace std;
void redirect_input() { freopen("/home/chgtaxihe/in", "r", stdin); }
void redirect_output() { freopen("/home/chgtaxihe/out", "w", stdout); }
void print_binary(int i) {
  int cnt = 0, temp = i;
  int save[33] = {0};
  while (temp) {
    if (temp & 1) save[cnt] = 1;
    cnt++;
    temp >>= 1;
  }
  for (int i = cnt - 1; i >= 0; i--) printf("%d", save[i]);
}
void print_array(int* begin, int* end) {
  int* t = begin;
  puts("print array start-------------");
  while (t != end) {
    printf("%d     ", *t);
    t++;
  }
  puts("\nprint array end-------------\n");
}
void print_array(int* begin, int* end, char* arr_name) {
  printf("print %s:\n", arr_name);
  print_array(begin, end);
}
void readint(int& p) {
  p = 0;
  int flag = 1;
  char c = getchar();
  while (c < '0' or c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c >= '0' and c <= '9') p = p * 10 + (c - '0'), c = getchar();
  p *= flag;
}
int readint() {
  int p = 0;
  int flag = 1;
  char c = getchar();
  while (c < '0' or c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c >= '0' and c <= '9') p = p * 10 + (c - '0'), c = getchar();
  p *= flag;
  return p;
}
const int inf = 0x3f3f3f3f;
const double dinf = 1e301;
void solve() {
  int l1, r1, l2, r2;
  scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
  for (int i = l1; i <= r1; i++) {
    for (int j = l2; j <= r2; j++) {
      if (i != j) {
        printf("%d %d\n", i, j);
        return;
      }
    }
  }
}
int main() {
  int test_kase;
  scanf("%d", &test_kase);
  for (int kase = 0; kase < test_kase; kase++) {
    solve();
  }
}
