#include <bits/stdc++.h>
int main() {
  int q;
  int a[510][2];
  int m = 0;
  int l1, r1, l2, r2;
  int flag;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
    flag = 0;
    for (int j = l1; j <= r1; j++) {
      a[m][0] = j;
      for (int k = l2; k <= r2; k++) {
        if (j != k) {
          flag = 1;
          a[m][1] = k;
          break;
        }
      }
      if (flag == 1) {
        m++;
        break;
      }
    }
  }
  for (int i = 0; i < q; i++) printf("%d %d\n", a[i][0], a[i][1]);
  return 0;
}
