#include <bits/stdc++.h>
int main() {
  int p;
  scanf("%d", &p);
  while (p--) {
    int l1, l2, r1, r2;
    scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
    int flag = 0;
    for (int i = l1; i <= r1; i++) {
      for (int j = l2; j <= r2; j++)
        if (i != j) {
          printf("%d %d\n", i, j);
          flag = 1;
          break;
        }
      if (flag == 1) break;
    }
  }
  return 0;
}
