#include <bits/stdc++.h>
using namespace std;
const int MAXN = 140011, MAXLOG = 20;
int ST[MAXN][MAXLOG][4];
int a[MAXN][4];
int lgdos[MAXN];
int n, m;
inline void Build() {
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 4; ++j) {
      ST[i][0][j] = a[i][j];
    }
  }
  lgdos[1] = 0;
  for (int i = 1; (1 << i) <= n; ++i) {
    lgdos[1 << i] = i;
    for (int j = 1; j + (1 << i) - 1 <= n; ++j) {
      for (int k = 0; k < 4; ++k) {
        if (k <= 1) {
          ST[j][i][k] = max(ST[j][i - 1][k], ST[j + (1 << (i - 1))][i - 1][k]);
        } else {
          ST[j][i][k] = min(ST[j][i - 1][k], ST[j + (1 << (i - 1))][i - 1][k]);
        }
      }
    }
  }
  for (int i = 2; i <= n; ++i) {
    if (!lgdos[i]) lgdos[i] = lgdos[i - 1];
  }
}
inline void Work(int l1, int r1, int l2, int r2) {
  int res[4];
  res[2] = res[3] = 1e9;
  res[0] = res[1] = -1e9;
  if (r1 >= l1 && l1 && r1 <= n) {
    int k = lgdos[r1 - l1 + 1];
    for (int i = 0; i < 4; ++i) {
      if (i <= 1) {
        res[i] = max(ST[l1][k][i], ST[r1 - (1 << k) + 1][k][i]);
      } else {
        res[i] = min(ST[l1][k][i], ST[r1 - (1 << k) + 1][k][i]);
      }
    }
  }
  if (r2 >= l2 && l2 && r2 <= n) {
    int k = lgdos[r2 - l2 + 1];
    for (int i = 0; i < 4; ++i) {
      if (i <= 1) {
        res[i] = max(res[i], max(ST[l2][k][i], ST[r2 - (1 << k) + 1][k][i]));
      } else {
        res[i] = min(res[i], min(ST[l2][k][i], ST[r2 - (1 << k) + 1][k][i]));
      }
    }
  }
  if (res[0] <= res[2] && res[1] <= res[3]) {
    printf("%d %d\n", res[0], res[1]);
    exit(0);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 4; ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  Build();
  for (int i = 1; i <= n; ++i) {
    Work(1, i - 1, i + 1, n);
  }
  puts("GG");
  return 0;
}
