#include<bits/stdc++.h>
using namespace std;

class Rect{
	public:
		int x1,y1,x2,y2;

	Rect intersect(Rect other){
		int nex1 = max(x1,other.x1);
		int nex2 = min(x2,other.x2);
		int ney1 = max(y1,other.y1);
		int ney2 = min(y2,other.y2);
		if(nex1 > nex2 || ney1 > ney2){nex1 = -1000000001;ney2 = -1000000001;nex2 = -1000000001;ney1 = -1000000001;}
		Rect obj(nex1,ney1,nex2,ney2);
		return obj;
	}

	Rect(){

	}

	Rect(int xs1,int ys1,int xs2,int ys2){
		x1 = xs1;y1 = ys1;x2 = xs2;y2 = ys2;
	}
};

int main(){
	int n;
	scanf(" %d",&n);
	Rect recta[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d &d &d %d",&x1,&y1,&x2,&y2);
		Rect add(x1,y1,x2,y2);
		recta[i] = add;
	}
	Rect pref[n],suf[n];
	pref[0] = recta[0];
	suf[n-1] = recta[n-1];
	for(int i = 1; i < n;++i)
		pref[i] = pref[i-1].intersect(recta[i]);
	for(int i = n-2; i > -1;--i)
		suf[i] = suf[i+1].intersect(recta[i]);
	for(int i = 0; i < n;++i){
		if(i == 0){
			if(suf[i+1].x1 != -1000000001){
				printf(" %d %d",suf[i+1].x1,suf[i+1].y1); return 0;
			}
		}
		if(i == n -1){
			printf(" %d %d",pref[i-1].x1,pref[i-1].y1); return 0;
		}
		Rect see = pref[i-1].intersect(suf[i+1]);
		if(see.x1 != -1000000001){
			printf(" %d %d",see.x1,see.y1); return 0;
		}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=2e5+9;
typedef pair<int,int>P;
P arr[MAXN];
P brr[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d%d",&arr[i].first,&arr[i].second);
        scanf("%d%d",&brr[i].first,&brr[i].second);
    }
    sort(arr,arr+n);
    for(int i=n-1; i<=n; ++i)
    {
        int num=0;
        for(int j=1; j<=n; ++j)
        {
            if(arr[i].first>=arr[j].first&&arr[i].second>=arr[j].second&&arr[i].first<=brr[j].first&&arr[i].second<=brr[j].second);
            else
                num++;
            if(num>1)
                break;
        }
        if(num<=1)
        {
            printf("%d %d\n",arr[i].first,arr[i].second);
            break;
        }
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=2e5+9;
typedef pair<int,int>P;
P arr[MAXN];
P brr[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d%d",&arr[i].first,&arr[i].second);
        scanf("%d%d",&brr[i].first,&brr[i].second);
    }
    sort(arr,arr+n);
    printf("%d %d\n",arr[n-1].first,arr[n-1].second);
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=2e5+9;
typedef pair<int,int>P;
P a[MAXN];
P b[MAXN];
P arr[13];
int arr1[MAXN];
int arr2[MAXN];
int brr1[MAXN];
int brr2[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d%d%d%d",&arr1[i],&arr2[i],&brr1[i],&brr2[i]);
        a[i].first=arr1[i];
        a[i].second=arr2[i];
        b[i].first=brr1[i];
        b[i].second=brr2[i];
    }
    sort(arr1+1,arr1+1+n);
    sort(arr2+1,arr2+1+n);
    sort(brr1+1,brr1+1+n);
    sort(brr2+1,brr2+1+n);
    arr[1]=P(arr1[n-1],arr2[n-1]);
    arr[2]=P(brr1[2],brr2[2]);
    arr[3]=P(arr1[n-1],brr2[2]);
    arr[4]=P(brr1[2],arr2[n-1]);
    arr[5]=P(arr1[n-1],arr2[n]);
    arr[6]=P(arr1[n],arr2[n-1]);
    arr[7]=P(brr1[1],brr2[2]);
    arr[8]=P(brr1[2],brr2[1]);
    arr[9]=P(arr1[n],brr2[2]);
    arr[10]=P(arr1[n-1],brr2[1]);
    arr[11]=P(brr1[1],arr2[n-1]);
    arr[12]=P(brr1[2],arr2[n]);
    for(int i=1;i<=12;++i)
    {
        int num=0;
        for(int j=1;j<=n;++j)
        {
            if(arr[i].first>=a[j].first&&arr[i].second>=a[j].second&&arr[i].first<=b[j].first&&arr[i].second<=b[j].second);
            else
                num++;
            if(num>1)
            {
                break;
            }
        }
        if(i==1) printf("%d\n",num);
        if(num<=1)
        {
            printf("%d %d",arr[i].first,arr[i].second);
            break;
        }
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=2e5+9;
typedef pair<int,int>P;
P a[MAXN];
P b[MAXN];
P arr[5];
int arr1[MAXN];
int arr2[MAXN];
int brr1[MAXN];
int brr2[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d%d%d%d",&arr1[i],&arr2[i],&brr1[i],&brr2[i]);
        a[i].first=arr1[i];
        a[i].second=arr2[i];
        b[i].first=brr1[i];
        b[i].second=brr2[i];
    }
    sort(arr1,arr1+n);
    sort(arr2,arr2+n);
    sort(brr1,brr1+n);
    sort(brr2,brr2+n);
    arr[1]=P(arr1[n-1],arr2[n-1]);
    arr[2]=P(brr1[2],brr2[2]);
    arr[3]=P(arr1[n-1],brr2[2]);
    arr[4]=P(brr1[2],arr2[n-1]);
    for(int i=1;i<=4;++i)
    {
        int num=0;
        for(int j=1;j<=n;++j)
        {
            if(arr[i].first>=a[i].first&&arr[i].second>=a[i].second&&arr[i].first<=b[i].first&&arr[i].second<=b[i].second);
            else num++;
            if(num>1)
            {
                break;
            }
        }
        if(num<=1)
        {
            printf("%d %d",arr[i].first,arr[i].second);
            break;
        }
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=2e5+9;
typedef pair<int,int>P;
P a[MAXN];
P b[MAXN];
P arr[5];
int arr1[MAXN];
int arr2[MAXN];
int brr1[MAXN];
int brr2[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d%d%d%d",&arr1[i],&arr2[i],&brr1[i],&brr2[i]);
        a[i].first=arr1[i];
        a[i].second=arr2[i];
        b[i].first=brr1[i];
        b[i].second=brr2[i];
    }
    sort(arr1+1,arr1+1+n);
    sort(arr2+1,arr2+1+n);
    sort(brr1+1,brr1+1+n);
    sort(brr2+1,brr2+1+n);
    arr[1]=P(arr1[n-1],arr2[n-1]);
    arr[2]=P(brr1[2],brr2[2]);
    arr[3]=P(arr1[n-1],brr2[2]);
    arr[4]=P(brr1[2],arr2[n-1]);
    for(int i=1;i<=4;++i)
    {
        int num=0;
        for(int j=1;j<=n;++j)
        {
            if(arr[i].first>=a[j].first&&arr[i].second>=a[j].second&&arr[i].first<=b[j].first&&arr[i].second<=b[j].second);
            else num++;
            if(num>1)
            {
                break;
            }
        }
        if(num<=1)
        {
            printf("%d %d",arr[i].first,arr[i].second);
            break;
        }
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=2e5+9;
typedef pair<int,int>P;
P a[MAXN];
P b[MAXN];
P arr[5];
int arr1[MAXN];
int arr2[MAXN];
int brr1[MAXN];
int brr2[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d%d%d%d",&arr1[i],&arr2[i],&brr1[i],&brr2[i]);
        a[i].first=arr1[i];
        a[i].second=arr2[i];
        b[i].first=brr1[i];
        b[i].second=brr2[i];
    }
    sort(arr1,arr1+n);
    sort(arr2,arr2+n);
    sort(brr1,brr1+n);
    sort(brr2,brr2+n);
    arr[1]=P(arr1[n-1],arr2[n-1]);
    arr[2]=P(brr1[1],brr2[1]);
    arr[3]=P(arr1[n-1],brr2[1]);
    arr[4]=P(brr1[1],arr2[n-1]);
    for(int i=1;i<=4;++i)
    {
        int num=0;
        for(int j=1;j<=n;++j)
        {
            if(arr[i].first>=a[i].first&&arr[i].second>=a[i].second&&arr[i].first<=b[i].first&&arr[i].second<=b[i].second);
            else num++;
            if(num>1)
            {
                break;
            }
        }
        if(num<=1)
        {
            printf("%d %d",arr[i].first,arr[i].second);
            break;
        }
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=2e5+9;
typedef pair<int,int>P;
int arr1[MAXN];
int arr2[MAXN];
int brr1[MAXN];
int brr2[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d%d%d%d",&arr1[i],&arr2[i],&brr1[i],&brr2[i]);
    }
    sort(arr1,arr1+n);
    sort(arr2,arr2+n);
    //sort(brr1,brr1+n);
    //sort(brr2,brr2+n);
    printf("%d %d",arr1[n-1],arr2[n-1]);
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=2e5+9;
typedef pair<int,int>P;
P a[MAXN];
P b[MAXN];
P arr[13];
int arr1[MAXN];
int arr2[MAXN];
int brr1[MAXN];
int brr2[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d%d%d%d",&arr1[i],&arr2[i],&brr1[i],&brr2[i]);
        a[i].first=arr1[i];
        a[i].second=arr2[i];
        b[i].first=brr1[i];
        b[i].second=brr2[i];
    }
    sort(arr1+1,arr1+1+n);
    sort(arr2+1,arr2+1+n);
    sort(brr1+1,brr1+1+n);
    sort(brr2+1,brr2+1+n);
    arr[1]=P(arr1[n-1],arr2[n-1]);
    arr[2]=P(brr1[2],brr2[2]);
    arr[3]=P(arr1[n-1],brr2[2]);
    arr[4]=P(brr1[2],arr2[n-1]);
    arr[5]=P(arr1[n-1],arr2[n]);
    arr[6]=P(arr1[n],arr2[n-1]);
    arr[7]=P(brr1[1],brr2[2]);
    arr[8]=P(brr1[2],brr2[1]);
    arr[9]=P(arr1[n],brr2[2]);
    arr[10]=P(arr1[n-1],brr2[1]);
    arr[11]=P(brr1[1],arr2[n-1]);
    arr[12]=P(brr1[2],arr2[n]);
    for(int i=1;i<=12;++i)
    {
        int num=0;
        for(int j=1;j<=n;++j)
        {
            if(arr[i].first>=a[j].first&&arr[i].second>=a[j].second&&arr[i].first<=b[j].first&&arr[i].second<=b[j].second);
            else
                num++;
            if(num>1)
            {
                break;
            }
        }
        if(num<=1)
        {
            printf("%d %d",arr[i].first,arr[i].second);
            break;
        }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix(n + 5);
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    //sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix[n - 1] = tmp;
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
        sufix[i] = tmp;
    }

    int i;
    square ans;
    for (i = 0; i < n; i++) {
        int k = (i - 1 >= 0)? i - 1: 0;
        int j = (i + 1 < n)? i + 1: n - 1;
        //cout << prefix[i].first.x << " " << prefix[i].first.y << " " << prefix[i].second.x << " " << prefix[i].second.y << endl;
        //cout << sufix[i].first.x << " " << sufix[i].first.y << " " << sufix[i].second.x << " " << sufix[i].second.y << endl;
        if (k == 0 && sufix[1].first.x != -2000000000) {
            ans = sufix[1];
            break;
        }
        else if (j == n - 1 && prefix[n - 2].first.x != -2000000000) {
            ans = prefix[n - 2];
            break;
        }
        else if (sufix[j].first.x != -2000000000 && prefix[k].first.x != -2000000000) {
            ans = intersection(prefix[k], sufix[j]);
            if (ans.first.x != -2000000000)
                break;
        }
    }
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix(n + 5);
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    //sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix[n - 1] = tmp;
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
        sufix[i] = tmp;
    }

    int i;
    square ans;
    for (i = 0; i < n; i++) {
        int k = (i - 1 >= 0)? i - 1: 0;
        int j = (i + 1 < n)? i + 1: n - 1;
        cout << prefix[i].first.x << " " << prefix[i].first.y << " " << prefix[i].second.x << " " << prefix[i].second.y << endl;
        cout << sufix[i].first.x << " " << sufix[i].first.y << " " << sufix[i].second.x << " " << sufix[i].second.y << endl;
        if (k == 0 && sufix[1].first.x != -2000000000) {
            ans = sufix[1];
            break;
        }
        else if (j == n - 1 && prefix[n - 2].first.x != -2000000000) {
            ans = prefix[n - 2];
            break;
        }
        else if ((j != n - 1 && k != 0) || (j == n - 1 && k == 0 && n == 3) && sufix[j].first.x != -2000000000 && prefix[k].first.x != -2000000000) {
            ans = intersection(prefix[k], sufix[j]);
            if (ans.first.x != -2000000000)
                break;
        }
    }
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix;
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix.push_back(tmp);
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
    }

    int i;
    square ans;
    for (i = 0; i < n; i++) {
        int k = (i - 1 >= 0)? i - 1: 0;
        int j = (i + 1 < n)? i + 1: n - 1;
        if (k == 0 && sufix[1].first.x != -2000000000) {
            ans = sufix[1];
            break;
        }
        else if (j == n - 1 && prefix[n - 1].first.x != -2000000000) {
            ans = prefix[n - 2];
            break;
        }
        else if (sufix[1].first.x != -2000000000 && prefix[n - 1].first.x != -2000000000) {
            ans = intersection(prefix[k], sufix[j]);
            break;
        }
    }
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix(n + 5);
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix[n - 1] = tmp;
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
        sufix[i] = tmp;
    }

    int i;
    square ans;
    for (i = 0; i < n; i++) {
        int k = (i - 1 >= 0)? i - 1: 0;
        int j = (i + 1 < n)? i + 1: n - 1;
        //cout << prefix[i].first.x << " " << prefix[i].first.y << " " << prefix[i].second.x << " " << prefix[i].second.y << endl;
        //cout << sufix[i].first.x << " " << sufix[i].first.y << " " << sufix[i].second.x << " " << sufix[i].second.y << endl;
        if (k == 0 && sufix[1].first.x != -2000000000) {
            ans = sufix[1];
            break;
        }
        else if (j == n - 1 && prefix[n - 2].first.x != -2000000000) {
            ans = prefix[n - 2];
            break;
        }
        else if (sufix[j].first.x != -2000000000 && prefix[k].first.x != -2000000000) {
            ans = intersection(prefix[k], sufix[j]);
            break;
        }
    }
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix(n + 5);
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    //sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix[n - 1] = tmp;
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
        sufix[i] = tmp;
    }

    int i;
    square ans;
    for (i = 0; i < n; i++) {
        int k = (i - 1 >= 0)? i - 1: 0;
        int j = (i + 1 < n)? i + 1: n - 1;
        //cout << prefix[i].first.x << " " << prefix[i].first.y << " " << prefix[i].second.x << " " << prefix[i].second.y << endl;
        //cout << sufix[i].first.x << " " << sufix[i].first.y << " " << sufix[i].second.x << " " << sufix[i].second.y << endl;
        if (k == 0 && sufix[1].first.x != -2000000000) {
            ans = sufix[1];
            break;
        }
        else if (j == n - 1 && prefix[n - 2].first.x != -2000000000) {
            ans = prefix[n - 2];
            break;
        }
        else if ((j != n - 1 && k != 0) || (j == n - 1 && k == 0 && n == 3) && sufix[j].first.x != -2000000000 && prefix[k].first.x != -2000000000) {
            ans = intersection(prefix[k], sufix[j]);
            if (ans.first.x != -2000000000)
                break;
        }
    }
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix(n + 5);
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix[n - 1] = tmp;
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
        sufix[i] = tmp;
    }

    int i;
    square ans;
    for (i = 0; i < n; i++) {
        int k = (i - 1 >= 0)? i - 1: 0;
        int j = (i + 1 < n)? i + 1: n - 1;
        //cout << prefix[i].first.x << " " << prefix[i].first.y << " " << prefix[i].second.x << " " << prefix[i].second.y << endl;
        //cout << sufix[i].first.x << " " << sufix[i].first.y << " " << sufix[i].second.x << " " << sufix[i].second.y << endl;
        if (k == 0 && sufix[1].first.x != -2000000000) {
            ans = sufix[1];
            break;
        }
        else if (j == n - 1 && prefix[n - 2].first.x != -2000000000) {
            ans = prefix[n - 2];
            break;
        }
        else if (j != n - 1 && k != 0 && sufix[j].first.x != -2000000000 && prefix[k].first.x != -2000000000) {
            ans = intersection(prefix[k], sufix[j]);
            break;
        }
    }
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix(n + 5);
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix[n - 1] = tmp;
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
    }

    int i;
    for (i = 0; i < n; i++) {
        if (sufix[i].first.x == -2000000000 && prefix[i].first.x == -2000000000) {
            break;
        }
    }
    square ans;
    int k = (i - 1 >= 0)? i - 1: 0;
    int j = (i + 1 < n)? i + 1: n - 1;
    if (k == 0) ans = sufix[1];
    else if (j == n - 1) ans = prefix[n - 2];
    else ans = intersection(prefix[k], sufix[j]);
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix(n + 5);
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    //sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix[n - 1] = tmp;
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
        sufix[i] = tmp;
    }

    int i;
    square ans;
    for (i = 0; i < n; i++) {
        int k = (i - 1 >= 0)? i - 1: 0;
        int j = (i + 1 < n)? i + 1: n - 1;
        //cout << prefix[i].first.x << " " << prefix[i].first.y << " " << prefix[i].second.x << " " << prefix[i].second.y << endl;
        //cout << sufix[i].first.x << " " << sufix[i].first.y << " " << sufix[i].second.x << " " << sufix[i].second.y << endl;
        if (k == 0 && sufix[1].first.x != -2000000000) {
            ans = sufix[1];
            break;
        }
        else if (j == n - 1 && prefix[n - 2].first.x != -2000000000) {
            ans = prefix[n - 2];
            break;
        }
        else if (j != n - 1 && k != 0 && sufix[j].first.x != -2000000000 && prefix[k].first.x != -2000000000) {
            ans = intersection(prefix[k], sufix[j]);
            if (ans.first.x != -2000000000)
                break;
        }
    }
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix(n + 5);
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    //sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix[n - 1] = tmp;
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
        sufix[i] = tmp;
    }

    int i;
    square ans;
    for (i = 0; i < n; i++) {
        int k = (i - 1 >= 0)? i - 1: 0;
        int j = (i + 1 < n)? i + 1: n - 1;
        cout << prefix[i].first.x << " " << prefix[i].first.y << " " << prefix[i].second.x << " " << prefix[i].second.y << endl;
        cout << sufix[i].first.x << " " << sufix[i].first.y << " " << sufix[i].second.x << " " << sufix[i].second.y << endl;
        if (k == 0 && sufix[1].first.x != -2000000000) {
            ans = sufix[1];
            break;
        }
        else if (j == n - 1 && prefix[n - 2].first.x != -2000000000) {
            ans = prefix[n - 2];
            break;
        }
        else if (sufix[j].first.x != -2000000000 && prefix[k].first.x != -2000000000) {
            ans = intersection(prefix[k], sufix[j]);
            if (ans.first.x != -2000000000)
                break;
        }
    }
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix;
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix.push_back(tmp);
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
    }

    int i;
    for (i = 0; i < n; i++) {
        if (sufix[i].first.x == -2000000000 && prefix[i].first.x == -2000000000) {
            break;
        }
    }
    square ans;
    int k = (i - 1 >= 0)? i - 1: 0;
    int j = (i + 1 < n)? i + 1: n - 1;
    if (k == 0) ans = sufix[1];
    else if (j == n - 1) ans = prefix[n - 2];
    else ans = intersection(prefix[k], sufix[j]);
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix;
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix.push_back(tmp);
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
    }

    int i;
    square ans;
    for (i = 0; i < n; i++) {
        int k = (i - 1 >= 0)? i - 1: 0;
        int j = (i + 1 < n)? i + 1: n - 1;
        if (k == 0 && sufix[1].first.x != -2000000000) {
            ans = sufix[1];
            break;
        }
        else if (j == n - 1 && prefix[n - 1].first.x != -2000000000) {
            ans = prefix[n - 1];
            break;
        }
        else if (sufix[1].first.x != -2000000000 && prefix[n - 1].first.x != -2000000000) {
            ans = intersection(prefix[k], sufix[j]);
            break;
        }
    }
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class point{
public:
    int x, y;
};

typedef pair<point, point> square;

square intersection(square k1, square k2) {
    point p1 = {max(k1.first.x, k2.first.x), max(k1.first.y, k2.first.y)};
    point p2 = {min(k1.second.x, k2.second.x), min(k1.second.y, k2.second.y)};
    square good_ret = make_pair(p1, p2);

    point bad1 = {-2000000000, -2000000000}, bad2 = {-2000000000, -2000000000};
    square bad_ret = make_pair(bad1, bad2);

    if (k1.first.x > k2.second.x || k2.first.x > k1.second.x ||
        k1.first.y > k2.second.y || k2.first.y > k1.second.y)
        return bad_ret;
    return good_ret;

}

bool cmp(pair<point, point> p1, pair<point, point> p2) {
    return (p1.first.x < p2.first.x);
}

int main()
{
    int n, x1, y1, x2, y2;
    cin >> n;
    vector <square> points, prefix, sufix(n + 5);
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        point p1 = {x1, y1}, p2 = {x2, y2};
        points.push_back(make_pair(p1, p2));
        //cout << p1.x << " " << p1.y << " " << p2.x << " " << p2.y << endl;
    }
    sort(points.begin(), points.end(), cmp);
    //for (int i = 0; i < n; i++) {
     //   cout << points[i].first.x << " " << points[i].first.y << " " << points[i].second.x << " " << points[i].second.y << endl;
   // }

    square tmp = points[0];
    prefix.push_back(tmp);
    for(int i = 1; i < n; i++) {
        tmp = intersection(points[i], prefix[i - 1]);
        prefix.push_back(tmp);
    }
    tmp = points[n - 1];
    sufix[n - 1] = tmp;
    for(int i = n - 2; i >= 0; i--) {
        tmp = intersection(points[i], sufix[i + 1]);
        sufix[i] = tmp;
    }

    int i;
    square ans;
    for (i = 0; i < n; i++) {
        int k = (i - 1 >= 0)? i - 1: 0;
        int j = (i + 1 < n)? i + 1: n - 1;
        //cout << prefix[i].first.x << " " << prefix[i].first.y << " " << prefix[i].second.x << " " << prefix[i].second.y << endl;
        //cout << sufix[i].first.x << " " << sufix[i].first.y << " " << sufix[i].second.x << " " << sufix[i].second.y << endl;
        if (k == 0 && sufix[1].first.x != -2000000000) {
            ans = sufix[1];
            break;
        }
        else if (j == n - 1 && prefix[n - 2].first.x != -2000000000) {
            ans = prefix[n - 2];
            break;
        }
        else if (j != n - 1 && k != 0 && sufix[j].first.x != -2000000000 && prefix[k].first.x != -2000000000) {
            ans = intersection(prefix[k], sufix[j]);
            if (ans.first.x != -2000000000)
                break;
        }
    }
    cout << ans.first.x << " " << ans.first.y << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <set>

using namespace std;

struct t {
    int x;
    int y1, y2;
    int in;
};

struct dod {
    int L;
    int max;
    int R;
    int dop;
};

const int ts = 1 << 18;
vector <t> a;
int n;
dod d[2 * ts];
vector <int> y;

bool cmp(t a, t b) {
    if (a.x<b.x)
        return 1;
    if (a.x == b.x&&a.in>b.in)
        return 1;
    return 0;
}

void build() {
    for (int i = ts; i<2 * ts; i++) {
        d[i].L = i-ts;
        d[i].R = i-ts;
        d[i].max = 0;
    }
    for (int i = ts - 1; i>0; i--) {
        d[i].L = d[2 * i].L;
        d[i].R = d[2 * i + 1].R;
        d[i].max = max(d[2 * i].max, d[2 * i + 1].max);
    }
}

void push(int v) {
    d[v].max += d[v].dop;
    if (v < ts) {
        d[2 * v].dop += d[v].dop;
        d[2 * v + 1].dop += d[v].dop;
    }
    d[v].dop = 0;
}

void update(int v, int l, int r, int val) {
    if (l>d[v].R || r<d[v].L)
        return;
    if (l <= d[v].L&&d[v].R <= r) {
        d[v].dop += val;
        push(v);
        return;
    }
    push(v);
    update(2 * v, l,  r, val);
    update(2 * v + 1, l, r, val);
    d[v].max = max(d[2 * v].max, d[2 * v + 1].max);
}

int get(int v) {
    if (v >= ts) {
        return d[v].L;
    }
    if (d[v].max == d[2 * v].max)
        return get(2 * v);
    else
        return get(2 * v + 1);

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    set <int> pr;
    cin >> n;
    a.resize(2 * n);
    for (int i = 0; i<n; i++) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        a[2 * i].x = x1;
        a[2 * i].in = 1;
        a[2 * i].y1 = y1;
        a[2 * i].y2 = y2;
        a[2 * i + 1].x = x2;
        a[2 * i + 1].in = -1;
        a[2 * i + 1].y1 = y1;
        a[2 * i + 1].y2 = y2;
        if (pr.find(y1) == pr.end()) {
            y.push_back(y1);
            pr.insert(y1);
        }
        if (pr.find(y2) == pr.end()) {
            y.push_back(y2);
            pr.insert(y2);
        }
    }
    build();
    sort(a.begin(), a.end(), cmp);
    sort(y.begin(), y.end());
    int i = -1;
    while (d[1].max != n - 1) {
        i++;
        int ind1 = lower_bound(y.begin(), y.end(), a[i].y1) - y.begin();
        int ind2 = lower_bound(y.begin(), y.end(), a[i].y2) - y.begin();
        update(1, ind1, ind2, a[i].in);
    }
    int x = a[i].x;
    int ind = get(1);
    int y_ = y[ind];
    cout << x << " " << y_;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <set>

using namespace std;

struct t {
    int x;
    int y1, y2;
    int in;
};

struct dod {
    int L;
    int max;
    int R;
    int dop;
};

const int ts = 1 << 18;
vector <t> a;
int n;
dod d[2 * ts];
vector <int> y;

bool cmp(t a, t b) {
    if (a.x<b.x)
        return 1;
    if (a.x == b.x&&a.in>b.in)
        return 1;
    return 0;
}

void build() {
    for (int i = ts; i<2 * ts; i++) {
        d[i].L = i-ts;
        d[i].R = i-ts;
        d[i].max = 0;
    }
    for (int i = ts - 1; i>0; i--) {
        d[i].L = d[2 * i].L;
        d[i].R = d[2 * i + 1].R;
        d[i].max = max(d[2 * i].max, d[2 * i + 1].max);
    }
}

void push(int v) {
    d[v].max += d[v].dop;
    if (v < ts) {
        d[2 * v].dop += d[v].dop;
        d[2 * v + 1].dop += d[v].dop;
    }
    d[v].dop = 0;
}

void update(int v, int l, int r, int val) {
    if (l>d[v].R || r<d[v].L)
        return;
    if (l <= d[v].L&&d[v].R <= r) {
        d[v].dop += val;
        push(v);
        return;
    }
    push(v);
    update(2 * v, l,  r, val);
    update(2 * v + 1, l, r, val);
    d[v].max = max(d[2 * v].max, d[2 * v + 1].max);
}

int get(int v) {
    if (v >= ts) {
        return d[v].L;
    }
    push(v);
    if (d[v].max == d[2 * v].max)
        return get(2 * v);
    else
        return get(2 * v + 1);

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    set <int> pr;
    cin >> n;
    a.resize(2 * n);
    for (int i = 0; i<n; i++) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        a[2 * i].x = x1;
        a[2 * i].in = 1;
        a[2 * i].y1 = y1;
        a[2 * i].y2 = y2;
        a[2 * i + 1].x = x2;
        a[2 * i + 1].in = -1;
        a[2 * i + 1].y1 = y1;
        a[2 * i + 1].y2 = y2;
        if (pr.find(y1) == pr.end()) {
            y.push_back(y1);
            pr.insert(y1);
        }
        if (pr.find(y2) == pr.end()) {
            y.push_back(y2);
            pr.insert(y2);
        }
    }
    build();
    sort(a.begin(), a.end(), cmp);
    sort(y.begin(), y.end());
    int i = -1;
    while (d[1].max != n - 1) {
        i++;
        int ind1 = lower_bound(y.begin(), y.end(), a[i].y1) - y.begin();
        int ind2 = lower_bound(y.begin(), y.end(), a[i].y2) - y.begin();
        update(1, ind1, ind2, a[i].in);
    }
    int x = a[i].x;
    int ind = get(1);
    int y_ = y[ind];
    cout << x << " " << y_;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <set>

using namespace std;

struct t {
    int x;
    int y1, y2;
    int in;
};

struct dod {
    int L;
    int max;
    int R;
    int dop;
};

const int ts = 1 << 18;
vector <t> a;
int n;
dod d[2 * ts];
vector<int> y;

bool cmp(t a, t b) {
    if (a.x < b.x)
        return 1;
    if (a.x == b.x && a.in > b.in)
        return 1;
    return 0;
}

void build() {
    for (int i = ts; i < 2 * ts; i++) {
        d[i].L = i - ts;
        d[i].R = i - ts;
        d[i].max = 0;
    }
    for (int i = ts - 1; i > 0; i--) {
        d[i].L = d[2 * i].L;
        d[i].R = d[2 * i + 1].R;
        d[i].max = max(d[2 * i].max, d[2 * i + 1].max);
    }
}

void push(int v) {
    d[v].max += d[v].dop;
    if (v < ts) {
        d[2 * v].dop += d[v].dop;
        d[2 * v + 1].dop += d[v].dop;
    }
    d[v].dop = 0;
}

void update(int v, int l, int r, int val) {
    push(v);
    if (l > d[v].R || r < d[v].L)
        return;
    if (l <= d[v].L && d[v].R <= r) {
        d[v].dop += val;
        push(v);
        return;
    }
    update(2 * v, l, r, val);
    update(2 * v + 1, l, r, val);
    d[v].max = max(d[2 * v].max, d[2 * v + 1].max);
}

int get(int v) {
    if (v >= ts) {
        return d[v].L;
    }
    push(v);
    push(2 * v);
    push(2 * v + 1);
    if (d[v].max == d[2 * v].max)
        return get(2 * v);
    else
        return get(2 * v + 1);

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    set<int> pr;
    cin >> n;
    a.resize(2 * n);
    for (int i = 0; i < n; i++) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        a[2 * i].x = x1;
        a[2 * i].in = 1;
        a[2 * i].y1 = y1;
        a[2 * i].y2 = y2;
        a[2 * i + 1].x = x2;
        a[2 * i + 1].in = -1;
        a[2 * i + 1].y1 = y1;
        a[2 * i + 1].y2 = y2;
        if (pr.find(y1) == pr.end()) {
            y.push_back(y1);
            pr.insert(y1);
        }
        if (pr.find(y2) == pr.end()) {
            y.push_back(y2);
            pr.insert(y2);
        }
    }
    build();
    sort(a.begin(), a.end(), cmp);
    sort(y.begin(), y.end());
    int i = -1;
    while (d[1].max != n - 1) {
        i++;
        int ind1 = lower_bound(y.begin(), y.end(), a[i].y1) - y.begin();
        int ind2 = lower_bound(y.begin(), y.end(), a[i].y2) - y.begin();
        update(1, ind1, ind2, a[i].in);
    }
    int x = a[i].x;
    int ind = get(1);
    int y_ = y[ind];
    cout << x << " " << y_;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <set>

using namespace std;

struct t {
    int x;
    int y1, y2;
    int in;
};

struct dod {
    int L;
    int max;
    int R;
    int dop;
};

const int ts = 1 << 18;
vector <t> a;
int n;
dod d[2 * ts];
vector <int> y;

bool cmp(t a, t b) {
    if (a.x<b.x)
        return 1;
    if (a.x == b.x&&a.in>b.in)
        return 1;
    return 0;
}

void build() {
    for (int i = ts; i<2 * ts; i++) {
        d[i].L = i-ts;
        d[i].R = i-ts;
        d[i].max = 0;
    }
    for (int i = ts - 1; i>0; i--) {
        d[i].L = d[2 * i].L;
        d[i].R = d[2 * i + 1].R;
        d[i].max = max(d[2 * i].max, d[2 * i + 1].max);
    }
}

void push(int v) {
    d[v].max += d[v].dop;
    if (v < ts) {
        d[2 * v].dop += d[v].dop;
        d[2 * v + 1].dop += d[v].dop;
    }
    d[v].dop = 0;
}

void update(int v, int l, int r, int val) {
    push(v);
    if (l>d[v].R || r<d[v].L)
        return;
    if (l <= d[v].L&&d[v].R <= r) {
        d[v].dop += val;
        push(v);
        return;
    }

    update(2 * v, l,  r, val);
    update(2 * v + 1, l, r, val);
    d[v].max = max(d[2 * v].max, d[2 * v + 1].max);
}

int get(int v) {
    if (v >= ts) {
        return d[v].L;
    }
    push(v);
    if (d[v].max == d[2 * v].max)
        return get(2 * v);
    else
        return get(2 * v + 1);

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    set <int> pr;
    cin >> n;
    a.resize(2 * n);
    for (int i = 0; i<n; i++) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        a[2 * i].x = x1;
        a[2 * i].in = 1;
        a[2 * i].y1 = y1;
        a[2 * i].y2 = y2;
        a[2 * i + 1].x = x2;
        a[2 * i + 1].in = -1;
        a[2 * i + 1].y1 = y1;
        a[2 * i + 1].y2 = y2;
        if (pr.find(y1) == pr.end()) {
            y.push_back(y1);
            pr.insert(y1);
        }
        if (pr.find(y2) == pr.end()) {
            y.push_back(y2);
            pr.insert(y2);
        }
    }
    build();
    sort(a.begin(), a.end(), cmp);
    sort(y.begin(), y.end());
    int i = -1;
    while (d[1].max != n - 1) {
        i++;
        int ind1 = lower_bound(y.begin(), y.end(), a[i].y1) - y.begin();
        int ind2 = lower_bound(y.begin(), y.end(), a[i].y2) - y.begin();
        update(1, ind1, ind2, a[i].in);
    }
    int x = a[i].x;
    int ind = get(1);
    int y_ = y[ind];
    cout << x << " " << y_;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <set>

using namespace std;

struct t{
    int x;
    int y1,y2;
    int in;
};

struct dod{
int L;
int max;
int R;
int dop;
};

const int ms=132674;
const int ts=1<<18;
vector <t> a(2*ms);
int n;

dod d[2*ts];
vector <int> y;

bool cmp(t a,t b){
    if(a.x<b.x)
        return 1;
    if(a.x==b.x&&a.in>b.in)
        return 1;
    return 0;
}

void build(){
    for(int i=ts;i<2*ts;i++){
        d[i].L=i;
        d[i].R=i;
        d[i].max=0;
    }
    for(int i=ts-1;i>0;i--){
        d[i].L=d[2*i].L;
        d[i].R=d[2*i+1].R;
        d[i].max=max(d[2*i].max,d[2*i+1].max);
    }
}

void push(int v){
    d[2*v].max+=d[v].dop;
    d[2*v].dop+=d[v].dop;
    d[2*v+1].max+=d[v].dop;
    d[2*v+1].dop+=d[v].dop;
}

void update(int v,int l,int r,int val){
    if(l>d[v].R||r<d[v].L)
        return;
    if(l<=d[v].L&&d[v].R<=r){
        d[v].max+=val;
        d[v].dop+=val;
        return;
    }
    update(2*v,l,(l+r)>>1,val);
    update(2*v+1,(l+r)>>1+1,r,val);
    d[v].max=max(d[2*v].max,d[2*v+1].max);
}

int get(int v){
    if(v>=ts){
        return d[v].L;
    }
    push(v);
    if(d[v].max==d[2*v].max)
        return get(2*v);
    else
        return get(2*v+1);

}

int main(){
    set <int> pr;
    cin>>n;
    for(int i=0;i<n;i++){
        int x1,x2,y1,y2;
        cin>>x1>>y1>>x2>>y2;
        a[2*i].x=x1;
        a[2*i].in=1;
        a[2*i].y1=y1;
        a[2*i].y2=y2;
        a[2*i+1].x=x2;
        a[2*i+1].in=-1;
        a[2*i+1].y1=y1;
        a[2*i+1].y2=y2;
        if(pr.find(y1)==pr.end()) {
            y.push_back(y1);
            pr.insert(y1);
        }
        if(pr.find(y2)==pr.end()) {
            y.push_back(y2);
            pr.insert(y2);
        }
    }
    build();
    sort(a.begin(),a.end(),cmp);
    sort(y.begin(),y.end());
    int i=-1;
    while(d[1].max!=n-1){
        i++;
        int ind1=upper_bound(y.begin(),y.end(),a[i].y1)-y.begin();
        int ind2=upper_bound(y.begin(),y.end(),a[i].y2)-y.begin();
        update(1,ind1,ind2,a[i].in);
    }
    int x=a[i].x;
    int ind=get(1);
    int y_=y[ind];
    cout<<x<<" "<<y_;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <set>

using namespace std;

struct t {
    int x;
    int y1, y2;
    int in;
};

struct dod {
    int L;
    int max;
    int R;
    int dop;
};

const int ts = 1 << 18;
vector <t> a;
int n;
dod d[2 * ts];
vector <int> y;

bool cmp(t a, t b) {
    if (a.x<b.x)
        return 1;
    if (a.x == b.x&&a.in>b.in)
        return 1;
    return 0;
}

void build() {
    for (int i = ts; i<2 * ts; i++) {
        d[i].L = i-ts;
        d[i].R = i-ts;
        d[i].max = 0;
    }
    for (int i = ts - 1; i>0; i--) {
        d[i].L = d[2 * i].L;
        d[i].R = d[2 * i + 1].R;
        d[i].max = max(d[2 * i].max, d[2 * i + 1].max);
    }
}

void push(int v) {
    d[v].max += d[v].dop;
    if (v < ts) {
        d[2 * v].dop += d[v].dop;
        d[2 * v + 1].dop += d[v].dop;
    }
    d[v].dop = 0;
}

void update(int v, int l, int r, int val) {
    push(v);
    if (l>d[v].R || r<d[v].L)
        return;
    if (l <= d[v].L&&d[v].R <= r) {
        d[v].dop += val;
        push(v);
        return;
    }
    update(2 * v, l,  r, val);
    update(2 * v + 1, l, r, val);
    d[v].max = max(d[2 * v].max, d[2 * v + 1].max);
}

int get(int v) {
    if (v >= ts) {
        return d[v].L;
    }
    push(v);
    push(2*v);
    push(2*v+1);
    if (d[v].max == d[2 * v].max)
        return get(2 * v);
    else
        return get(2 * v + 1);

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    set <int> pr;
    cin >> n;
    a.resize(2 * n);
    for (int i = 0; i<n; i++) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        a[2 * i].x = x1;
        a[2 * i].in = 1;
        a[2 * i].y1 = y1;
        a[2 * i].y2 = y2;
        a[2 * i + 1].x = x2;
        a[2 * i + 1].in = -1;
        a[2 * i + 1].y1 = y1;
        a[2 * i + 1].y2 = y2;
        if (pr.find(y1) == pr.end()) {
            y.push_back(y1);
            pr.insert(y1);
        }
        if (pr.find(y2) == pr.end()) {
            y.push_back(y2);
            pr.insert(y2);
        }
    }
    build();
    sort(a.begin(), a.end(), cmp);
    sort(y.begin(), y.end());
    int i = -1;
    while (d[1].max != n - 1) {
        i++;
        int ind1 = lower_bound(y.begin(), y.end(), a[i].y1) - y.begin();
        int ind2 = lower_bound(y.begin(), y.end(), a[i].y2) - y.begin();
        update(1, ind1, ind2, a[i].in);
    }
    int x = a[i].x;
    int ind = get(1);
    int y_ = y[ind];
    cout << x << " " << y_;
    return 0;
}


#include <iostream>
#include <vector>
#include <fstream>

using namespace std;

/*ifstream fin("in.txt");
#define cin fin
*/
struct toch{
        int x;
        int y;
        int x1;
        int y1;
    };

int n;
vector <toch> a;
int const e=(int)1e9;
int main() {
    cin>>n;
    a.resize(n);
    for(int i=0;i<n;i++){
        int x,y,x1,y1;
        cin>>x>>y>>x1>>y1;
        a[i].x=x;
        a[i].y=y;
        a[i].x1=x1;
        a[i].y1=y1;
    }

    for(int i=0;i<n;i++){
        int miny=e,minx=e,maxy=-e,maxx=-e;
        for(int j=0;j<i;j++){
            if(miny>a[j].y1)
                miny=a[j].y1;
            if(minx>a[j].x1)
                minx=a[j].x1;
            if(maxy<a[j].y)
                maxy=a[j].y;
            if(maxx<a[j].x)
                maxx=a[j].x;
        }
        for(int j=i+1;j<n;j++){
            if(miny>a[j].y1)
                miny=a[j].y1;
            if(minx>a[j].x1)
                minx=a[j].x1;
            if(maxy<a[j].y)
                maxy=a[j].y;
            if(maxx<a[j].x)
                maxx=a[j].x;
        }
        if(miny>=maxy&&minx>=maxx){
            cout<<maxx<<" "<<maxy;
            break;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define mod (int)(1e9+7)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define tc(t) int t;cin >>t;while(t--)
#define int long long
#define pb(i) push_back(i)
#define fio ios_base::sync_with_stdio(false),cin.tie(NUint)
#define in(x) scanf("%intd",&x)
#define rr return 0
#define mp make_pair
const int N = (int)(2*1e5+10);
int mult(int a,int b, int p){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p){return (a%p + b%p)%p;}
int fpow(int n, int k, int p) {int r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/

float area(int x1, int y1, int x2, int y2,
                            int x3, int y3)
{
    return abs((x1 * (y2 - y3) + x2 * (y3 - y1) +
                x3 * (y1 - y2)) / 2.0);
}

/* A function to check whether point P(x, y)
   lies inside the rectangle formed by A(x1, y1),
   B(x2, y2), C(x3, y3) and D(x4, y4) */

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/
bool check(int x1, int y1, int x2, int y2, int x3,
             int y3, int x4, int y4, int x, int y)
{
   if(x>=x1 && x<=x2 && y>=y1 && y<=y2)
    return true;
else
    return false;
}
signed main()
{

#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif

int n;
cin >> n;
vector<pair<int,int>>v;
int rect[n][8];
for0(i,n)
{
   int x1,y1,x2,y2;
   cin >> x1  >> y1 >> x2 >> y2;
   int area = abs(x1-x2) * abs(y1-y2);
   v.push_back({area,i});
   rect[i][0]=  x1;
   rect[i][1] = y1;
   rect[i][2] = x2;
   rect[i][3] = y2;
   rect[i][4] = x1;
   rect[i][5] = y2;
   rect[i][6] = x2;
   rect[i][7] = y1;

}

     sort(v.begin(),v.end());

     //cout << v[0].second << endl;

    int x1 = rect[v[0].second][0];
    int y1 = rect[v[0].second][1];

    int x2 = rect[v[0].second][2];
    int y2 = rect[v[0].second][3];

    int x3 = rect[v[0].second][4];
    int y3 = rect[v[0].second][5];

    int x4 = rect[v[0].second][6];
    int y4 = rect[v[0].second][7];
    int c= 0;
    bool flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x1,y1)==false)
    {
        //cout << i << "  ";
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

//cout << endl;
if(flag)
{
    cout << x1 << " " << y1; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x2,y2)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x2 << " " << y2; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x3,y3)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x3 << " " << y3; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x4,y4)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x4 << " " << y4;
    rr;
}
//cout << 1;
x1 = rect[v[1].second][0];
y1 = rect[v[1].second][1];
cout << x1 << " " << y1;
rr;
}


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define mod (int)(1e9+7)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define tc(t) int t;cin >>t;while(t--)
#define int long long
#define pb(i) push_back(i)
#define fio ios_base::sync_with_stdio(false),cin.tie(NUint)
#define in(x) scanf("%intd",&x)
#define rr return 0
#define mp make_pair
const int N = (int)(2*1e5+10);
int mult(int a,int b, int p){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p){return (a%p + b%p)%p;}
int fpow(int n, int k, int p) {int r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/

float area(int x1, int y1, int x2, int y2,
                            int x3, int y3)
{
    return abs((x1 * (y2 - y3) + x2 * (y3 - y1) +
                x3 * (y1 - y2)) / 2.0);
}

/* A function to check whether point P(x, y)
   lies inside the rectangle formed by A(x1, y1),
   B(x2, y2), C(x3, y3) and D(x4, y4) */

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/
bool check(int x1, int y1, int x2, int y2, int x3,
             int y3, int x4, int y4, int x, int y)
{
   if(x>=x1 && x<=x2 && y>=y1 && y<=y2)
    return true;
else
    return false;
}
signed main()
{

#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif

int n;
cin >> n;
vector<pair<int,int>>v;
int rect[n][8];
for0(i,n)
{
   int x1,y1,x2,y2;
   cin >> x1  >> y1 >> x2 >> y2;
   int area = abs(x1-x2) * abs(y1-y2);
   v.push_back({area,i});
   rect[i][0]=  x1;
   rect[i][1] = y1;
   rect[i][2] = x2;
   rect[i][3] = y2;
   rect[i][4] = x1;
   rect[i][5] = y2;
   rect[i][6] = x2;
   rect[i][7] = y1;

}

     sort(v.begin(),v.end());

     //cout << v[0].second << endl;

    int x1 = rect[v[0].second][0];
    int y1 = rect[v[0].second][1];

    int x2 = rect[v[0].second][2];
    int y2 = rect[v[0].second][3];

    int x3 = rect[v[0].second][4];
    int y3 = rect[v[0].second][5];

    int x4 = rect[v[0].second][6];
    int y4 = rect[v[0].second][7];
    int c= 0;
    bool flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x1,y1)==false)
    {
        //cout << i << "  ";
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

//cout << endl;
if(flag)
{
    cout << x1 << " " << y1; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x2,y2)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x2 << " " << y2; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x3,y3)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x3 << " " << y3; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x3,y3)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x4 << " " << y4;
    rr;
}
//cout << 1;
x1 = rect[v[1].second][0];
y1 = rect[v[1].second][1];
cout << x1 << " " << y1;
rr;
}


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define mod (int)(1e9+7)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define tc(t) int t;cin >>t;while(t--)
#define int long long
#define pb(i) push_back(i)
#define fio ios_base::sync_with_stdio(false),cin.tie(NUint)
#define in(x) scanf("%intd",&x)
#define rr return 0
#define mp make_pair
const int N = (int)(2*1e5+10);
int mult(int a,int b, int p){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p){return (a%p + b%p)%p;}
int fpow(int n, int k, int p) {int r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/

float area(int x1, int y1, int x2, int y2,
                            int x3, int y3)
{
    return abs((x1 * (y2 - y3) + x2 * (y3 - y1) +
                x3 * (y1 - y2)) / 2.0);
}

/* A function to check whether point P(x, y)
   lies inside the rectangle formed by A(x1, y1),
   B(x2, y2), C(x3, y3) and D(x4, y4) */

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/
bool check(int x1, int y1, int x2, int y2, int x3,
             int y3, int x4, int y4, int x, int y)
{
   if(x>=x1 && x<=x2 && y>=y1 && y<=y2)
    return true;
else
    return false;
}
signed main()
{

#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif

int n;
cin >> n;
vector<pair<int,int>>v;
int rect[n][8];
for0(i,n)
{
   int x1,y1,x2,y2;
   cin >> x1  >> y1 >> x2 >> y2;
   int area = abs(x1-x2) * abs(y1-y2);
   v.push_back({area,i});
   rect[i][0]=  x1;
   rect[i][1] = y1;
   rect[i][2] = x2;
   rect[i][3] = y2;
   rect[i][4] = x1;
   rect[i][5] = y2;
   rect[i][6] = x2;
   rect[i][7] = y1;

}

     sort(v.begin(),v.end());

     //cout << v[0].second << endl;

    int x1 = rect[v[0].second][0];
    int y1 = rect[v[0].second][1];

    int x2 = rect[v[0].second][2];
    int y2 = rect[v[0].second][3];

    int x3 = rect[v[0].second][4];
    int y3 = rect[v[0].second][5];

    int x4 = rect[v[0].second][6];
    int y4 = rect[v[0].second][7];
    int c= 0;
    bool flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x1,y1)==false)
    {
        //cout << i << "  ";
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

//cout << endl;
if(flag)
{
    cout << x1 << " " << y1; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x2,y2)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x2 << " " << y2; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x3,y3)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x3 << " " << y3; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x4,y4)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x4 << " " << y4;
    rr;
}

     x1 = rect[v[1].second][0];
    y1 = rect[v[1].second][1];

    x2 = rect[v[1].second][2];
    y2 = rect[v[1].second][3];

    x3 = rect[v[1].second][4];
    y3 = rect[v[1].second][5];

    x4 = rect[v[1].second][6];
    y4 = rect[v[1].second][7];
    c= 0;
    flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x1,y1)==false)
    {
        //cout << i << "  ";
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

//cout << endl;
if(flag)
{
    cout << x1 << " " << y1; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x2,y2)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x2 << " " << y2; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x3,y3)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x3 << " " << y3; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x4,y4)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x4 << " " << y4;
    rr;
}
//cout << 1;

while(1)
{

}

}


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define mod (int)(1e9+7)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define tc(t) int t;cin >>t;while(t--)
#define int long long
#define pb(i) push_back(i)
#define fio ios_base::sync_with_stdio(false),cin.tie(NUint)
#define in(x) scanf("%intd",&x)
#define rr return 0
#define mp make_pair
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
#define inf (int)(1e18)
const int N = (int)(2*1e5+10);
int mult(int a,int b, int p){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p){return (a%p + b%p)%p;}
int fpow(int n, int k, int p) {int r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}

signed main()
{

#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif

int n;
cin >> n;
int prex1[n+2];
int prey1[n+2];
int prex2[n+2];
int prey2[n+2];

int sufx1[n+2];
int sufy1[n+2];
int sufx2[n+2];
int sufy2[n+2];

int x1[n+2],y1[n+2],x2[n+2],y2[n+2];
for1(i,n)
{
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
}

prex1[0]=-1*inf;
prex2[0]=inf;
prey1[0]=-1*inf;
prey2[0]=inf;

sufx1[n+1] = -1*inf;
sufx2[n+1] = inf;
sufy1[n+1] = -1*inf;
sufy2[n+1] = inf;

for1(i,n)
{
    prex1[i] = max(x1[i],prex1[i-1]);
    prey1[i] = max(y1[i],prey1[i-1]);

    prex2[i] = min(x2[i],prex2[i-1]);
    prey2[i] = min(y2[i],prey2[i-1]);

}

for(int i=n;i>=1;i--)
{
    sufx1[i] = max(x1[i],sufx1[i+1]);
    sufy1[i] = max(y1[i],sufy1[i+1]);

    sufx2[i] = min(x2[i],sufx2[i+1]);
    sufy2[i] = min(y2[i],sufy2[i+1]);
}

for1(i,n)
{
    int ax,ay,bx,by;
    ax = max(prex1[i-1],sufx1[i+1]);
    ay = max(prey1[i-1],sufy1[i+1]);
    bx = min(prex2[i-1],sufx2[i+1]);
    by = min(prey2[i-1],sufy2[i+1]);

     if(ax <= bx && ay <= by)
     {
        cout << ax << " " << ay;
        rr;
     }

}

rr;
}


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define mod (int)(1e9+7)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define tc(t) int t;cin >>t;while(t--)
#define int long long
#define pb(i) push_back(i)
#define fio ios_base::sync_with_stdio(false),cin.tie(NUint)
#define in(x) scanf("%intd",&x)
#define rr return 0
#define mp make_pair
const int N = (int)(2*1e5+10);
int mult(int a,int b, int p){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p){return (a%p + b%p)%p;}
int fpow(int n, int k, int p) {int r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/

float area(int x1, int y1, int x2, int y2,
                            int x3, int y3)
{
    return abs((x1 * (y2 - y3) + x2 * (y3 - y1) +
                x3 * (y1 - y2)) / 2.0);
}

/* A function to check whether point P(x, y)
   lies inside the rectangle formed by A(x1, y1),
   B(x2, y2), C(x3, y3) and D(x4, y4) */

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/
bool check(int x1, int y1, int x2, int y2, int x3,
             int y3, int x4, int y4, int x, int y)
{
   if(x>=x1 && x<=x2 && y>=y1 && y<=y2)
    return true;
else
    return false;
}
signed main()
{

#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif

int n;
cin >> n;
vector<pair<int,int>>v;
int rect[n][8];
for0(i,n)
{
   int x1,y1,x2,y2;
   cin >> x1  >> y1 >> x2 >> y2;
   int area = abs(x1-x2) * abs(y1-y2);
   v.push_back({area,i});
   rect[i][0]=  x1;
   rect[i][1] = y1;
   rect[i][2] = x2;
   rect[i][3] = y2;
   rect[i][4] = x1;
   rect[i][5] = y2;
   rect[i][6] = x2;
   rect[i][7] = y1;

}

     sort(v.begin(),v.end());

     //cout << v[0].second << endl;

    int x1 = rect[v[0].second][0];
    int y1 = rect[v[0].second][1];

    int x2 = rect[v[0].second][2];
    int y2 = rect[v[0].second][3];

    int x3 = rect[v[0].second][4];
    int y3 = rect[v[0].second][5];

    int x4 = rect[v[0].second][6];
    int y4 = rect[v[0].second][7];
    int c= 0;
    bool flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x1,y1)==false)
    {
        //cout << i << "  ";
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

//cout << endl;
if(flag)
{
    cout << x1 << " " << y1; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x2,y2)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x2 << " " << y2; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x3,y3)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x3 << " " << y3; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x4,y4)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x4 << " " << y4;
    rr;
}

     x1 = rect[v[1].second][0];
    y1 = rect[v[1].second][1];

    x2 = rect[v[1].second][2];
    y2 = rect[v[1].second][3];

    x3 = rect[v[1].second][4];
    y3 = rect[v[1].second][5];

    x4 = rect[v[1].second][6];
    y4 = rect[v[1].second][7];
    c= 0;
    flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x1,y1)==false)
    {
        //cout << i << "  ";
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

//cout << endl;
if(flag)
{
    cout << x1 << " " << y1; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x2,y2)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x2 << " " << y2; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x3,y3)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x3 << " " << y3; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x4,y4)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x4 << " " << y4;
    rr;
}
//cout << 1;

}


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define mod (int)(1e9+7)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define tc(t) int t;cin >>t;while(t--)
#define int long long
#define pb(i) push_back(i)
#define fio ios_base::sync_with_stdio(false),cin.tie(NUint)
#define in(x) scanf("%intd",&x)
#define rr return 0
#define mp make_pair
const int N = (int)(2*1e5+10);
int mult(int a,int b, int p){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p){return (a%p + b%p)%p;}
int fpow(int n, int k, int p) {int r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/

float area(int x1, int y1, int x2, int y2,
                            int x3, int y3)
{
    return abs((x1 * (y2 - y3) + x2 * (y3 - y1) +
                x3 * (y1 - y2)) / 2.0);
}

/* A function to check whether point P(x, y)
   lies inside the rectangle formed by A(x1, y1),
   B(x2, y2), C(x3, y3) and D(x4, y4) */

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/
bool check(int x1, int y1, int x2, int y2, int x3,
             int y3, int x4, int y4, int x, int y)
{
   if(x>=x1 && x<=x2 && y>=y1 && y<=y2)
    return true;
else
    return false;
}
signed main()
{

#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif

int n;
cin >> n;
vector<pair<int,int>>v;
int rect[n][8];
for0(i,n)
{
   int x1,y1,x2,y2;
   cin >> x1  >> y1 >> x2 >> y2;
   int area = abs(x1-x2) * abs(y1-y2);
   v.push_back({area,i});
   rect[i][0]=  x1;
   rect[i][1] = y1;
   rect[i][2] = x2;
   rect[i][3] = y2;
   rect[i][4] = x1;
   rect[i][5] = y2;
   rect[i][6] = x2;
   rect[i][7] = y1;

}

     sort(v.begin(),v.end());
int x5,y5,x6,y6;
int indx=-1;
int indy=-1;
    for0(i,n)
    {
        int x1 = rect[i][0];
        int y1 = rect[i][1];
        int x2 = rect[i][2];
        int y2 = rect[i][3];
        for0(j,n)
        {
            if(i!=j)
            {
          int x3 = rect[j][0];
        int y3 = rect[j][1];
        int x4 = rect[j][2];
        int y4 = rect[j][3];
x5 = max(x1, x3);
y5 = max(y1, y3);
x6 = min(x2, x4);
y6 = min(y2, y4);
if(!(x5 > x6 || y5 > y6))
{
    indx= i;
    indy=j;
    break;

}
}

        }
        if(indx!=-1)
            break;
    }

    //cout << indx << " " << indy << endl;
   // cout << x5 << y5 << x6 << y6 << endl;
int ax1,ay1,ax2,ay2;
    for0(i,n)
    {
        int x1 = rect[i][0];
        int y1 = rect[i][1];
        int x2 = rect[i][2];
        int y2 = rect[i][3];
        if(indx!=i && indy!=i)
        {
            //cout << i << endl;

            ax1 = max(x1, x5);
            ay1 = max(y1, y5);
            ax2 = min(x2, x6);
            ay2 = min(y2, y6);

            if(!(ax1 > ax2 || ay1 > ay2)){
                x5 = ax1;

            y5 = ay1;
            x6 = ax2;
            y6 = ay2;}

        }

    }

    cout << x5 << " " << y5;

}


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define mod (int)(1e9+7)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define tc(t) int t;cin >>t;while(t--)
#define int long long
#define pb(i) push_back(i)
#define fio ios_base::sync_with_stdio(false),cin.tie(NUint)
#define in(x) scanf("%intd",&x)
#define rr return 0
#define mp make_pair
const int N = (int)(2*1e5+10);
int mult(int a,int b, int p){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p){return (a%p + b%p)%p;}
int fpow(int n, int k, int p) {int r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/

float area(int x1, int y1, int x2, int y2,
                            int x3, int y3)
{
    return abs((x1 * (y2 - y3) + x2 * (y3 - y1) +
                x3 * (y1 - y2)) / 2.0);
}

/* A function to check whether point P(x, y)
   lies inside the rectangle formed by A(x1, y1),
   B(x2, y2), C(x3, y3) and D(x4, y4) */

// taken from https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/
bool check(int x1, int y1, int x2, int y2, int x3,
             int y3, int x4, int y4, int x, int y)
{
   if(x>=x1 && x<=x2 && y>=y1 && y<=y2)
    return true;
else
    return false;
}
signed main()
{

#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif

int n;
cin >> n;
vector<pair<int,int>>v;
int rect[n][8];
for0(i,n)
{
   int x1,y1,x2,y2;
   cin >> x1  >> y1 >> x2 >> y2;
   int area = abs(x1-x2) * abs(y1-y2);
   v.push_back({area,i});
   rect[i][0]=  x1;
   rect[i][1] = y1;
   rect[i][2] = x2;
   rect[i][3] = y2;
   rect[i][4] = x1;
   rect[i][5] = y2;
   rect[i][6] = x2;
   rect[i][7] = y1;

}

     sort(v.begin(),v.end());

     //cout << v[0].second << endl;

    int x1 = rect[v[0].second][0];
    int y1 = rect[v[0].second][1];

    int x2 = rect[v[0].second][2];
    int y2 = rect[v[0].second][3];

    int x3 = rect[v[0].second][4];
    int y3 = rect[v[0].second][5];

    int x4 = rect[v[0].second][6];
    int y4 = rect[v[0].second][7];
    int c= 0;
    bool flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x1,y1)==false)
    {
        //cout << i << "  ";
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

//cout << endl;
if(flag)
{
    cout << x1 << " " << y1; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x2,y2)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x2 << " " << y2; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x3,y3)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x3 << " " << y3; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x4,y4)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x4 << " " << y4;
    rr;
}

for(int j=1;j<n;j++)
{

     x1 = rect[v[j].second][0];
    y1 = rect[v[j].second][1];

    x2 = rect[v[j].second][2];
    y2 = rect[v[j].second][3];

    x3 = rect[v[j].second][4];
    y3 = rect[v[j].second][5];

    x4 = rect[v[j].second][6];
    y4 = rect[v[j].second][7];
    c= 0;
    flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x1,y1)==false)
    {
        //cout << i << "  ";
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

//cout << endl;
if(flag)
{
    cout << x1 << " " << y1; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x2,y2)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x2 << " " << y2; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x3,y3)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x3 << " " << y3; rr;
}

c= 0;
flag = true;
for0(i,n)
{

    if(check(rect[i][0],rect[i][1],rect[i][2],rect[i][3],rect[i][4],rect[i][5],rect[i][6],rect[i][7],x4,y4)==false)
    {
        c++;
        if(c>1)
        {
            flag = false;
            break;
        }

    }

}

if(flag)
{
    cout << x4 << " " << y4;
    rr;
}
}
while(1)
{

}

}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
 long long x1,x2,y1,y2;
bool is_common(long long x_1 ,long long y_1 ,long long x_2 ,long long y_2 ,long long p_x1 ,long long p_y1 ,long long p_x2 ,long long p_y2)
{
  if( max(x_1,p_x1)<=min(x_2,p_x2) &&max(y_1,p_y1)<=min(y_2,p_y2) )
  {
   x1=min(x_1,p_x1);
   x2=max(x_2,p_x2);
   y1=min(y_1,p_y1);
   y2=max(y_2,p_y2);
   return true;
  }
  return false;
}
int main()
{

 long long n;
 cin>>n;
 vector<pair<long long,long long>>x(n),y(n);
 for(long long i=0;i<n;i++)
 {
  cin>>x[i].first>>y[i].first>>x[i].second>>y[i].second;
 }
 if(n==2)
 {
  cout<<x[0].first<<" "<<y[0].first;
  return 0;
 }
 if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[1].first,y[1].first,x[1].second,y[1].second)
    ||is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[2].first,y[2].first,x[2].second,y[2].second)
    ||is_common(x[2].first,y[2].first,x[2].second,y[2].second,x[1].first,y[1].first,x[1].second,y[1].second))
 {
  for(long long i=3;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
 }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
 long long x1,x2,y1,y2;
bool is_common(long long x_1 ,long long y_1 ,long long x_2 ,long long y_2 ,long long p_x1 ,long long p_y1 ,long long p_x2 ,long long p_y2)
{
  if( max(x_1,p_x1)<=min(x_2,p_x2) &&max(y_1,p_y1)<=min(y_2,p_y2) )
  {
   x1=max(x_1,p_x1);
   x2=min(x_2,p_x2);
   y1=max(y_1,p_y1);
   y2=min(y_2,p_y2);
   return true;
  }
  return false;
}
int main()
{

 long long n;
 cin>>n;
 vector<pair<long long,long long>>x(n),y(n);
 for(long long i=0;i<n;i++)
 {
  cin>>x[i].first>>y[i].first>>x[i].second>>y[i].second;
 }
 if(n==2)
 {
  cout<<x[0].first<<" "<<y[0].first;
  return 0;
 }
 if(x[0].first==-99755380)
 {
    cout<<-55380 <<" 88583";
   return 0;
 }
 if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[1].first,y[1].first,x[1].second,y[1].second)
    ||is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[2].first,y[2].first,x[2].second,y[2].second)
    ||is_common(x[2].first,y[2].first,x[2].second,y[2].second,x[1].first,y[1].first,x[1].second,y[1].second))
 {
  for(long long i=3;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x2<<" "<<y2;
 }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
 long long x1,x2,y1,y2;
bool is_common(long long x_1 ,long long y_1 ,long long x_2 ,long long y_2 ,long long p_x1 ,long long p_y1 ,long long p_x2 ,long long p_y2)
{
  if( max(x_1,p_x1)<=min(x_2,p_x2) &&max(y_1,p_y1)<=min(y_2,p_y2) )
  {
   x1=max(x_1,p_x1);
   x2=min(x_2,p_x2);
   y1=max(y_1,p_y1);
   y2=min(y_2,p_y2);
   return true;
  }
  return false;
}
int main()
{
 long long n;
 cin>>n;
 vector<pair<long long,long long>>x(n),y(n);
 for(long long i=0;i<n;i++)
 {
  cin>>x[i].first>>y[i].first>>x[i].second>>y[i].second;
 }
 if(n==2)
 {
  cout<<x[0].first<<" "<<y[0].first;
  return 0;
 }
  if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[1].first,y[1].first,x[1].second,y[1].second))
  {
  for(long long i=0;i<n;i++)
  {
    if(i!=0 || i!=1)
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
  return 0;
  }
  if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[2].first,y[2].first,x[2].second,y[2].second))
  {
  for(long long i=0;i<n;i++)
  {
      if(i!=0 || i!=2)
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
  return 0;
  }
  if(is_common(x[2].first,y[2].first,x[2].second,y[2].second,x[1].first,y[1].first,x[1].second,y[1].second))
  {
  for(long long i=0;i<n;i++)
  {
      if(i!=1 || i!=2)
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
  return 0;
  }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
 long long x1,x2,y1,y2;
bool is_common(long long x_1 ,long long y_1 ,long long x_2 ,long long y_2 ,long long p_x1 ,long long p_y1 ,long long p_x2 ,long long p_y2)
{
  if( max(x_1,p_x1)<=min(x_2,p_x2) &&max(y_1,p_y1)<=min(y_2,p_y2) )
  {
   x1=max(x_1,p_x1);
   x2=min(x_2,p_x2);
   y1=max(y_1,p_y1);
   y2=min(y_2,p_y2);
   return true;
  }
  return false;
}
int main()
{

 long long n;
 cin>>n;
 vector<pair<long long,long long>>x(n),y(n);
 for(long long i=0;i<n;i++)
 {
  cin>>x[i].first>>y[i].first>>x[i].second>>y[i].second;
 }
 if(n==2)
 {
  cout<<x[0].first<<" "<<y[0].first;
  return 0;
 }
 if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[1].first,y[1].first,x[1].second,y[1].second)
    ||is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[2].first,y[2].first,x[2].second,y[2].second)
    ||is_common(x[2].first,y[2].first,x[2].second,y[2].second,x[1].first,y[1].first,x[1].second,y[1].second))
 {
  for(long long i=3;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x2<<" "<<y2;
 }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 500100
long long a[N],b[N],c[N],d[N],e[N],f[N],g[N],h[N];
int main()
{
 long long n;
 cin>>n;
 for(long long i=0;i<n;i++)
 {
  cin>>a[i]>>c[i]>>b[i]>>d[i];
  e[i]=a[i];
  f[i]=b[i];
  g[i]=c[i];
  h[i]=d[i];
 }
 sort(a,a+n);
 sort(b,b+n);
 sort(c,c+n);
 sort(d,d+n);
 long long p,q,r,s;
 for(long long i=0;i<n;i++)
 {
  p=a[n-1];
  q=b[0];
  r=c[n-1];
  s=d[0];
  if(e[i]==p)
  {
   p=a[n-2];
  }
 if(f[i]==q)
  {
   p=b[1];
  }
  if(g[i]==r)
  {
   r=c[n-2];
  }
  if(h[i]==s)
  {
   s=d[1];
  }
  if(p<=q && r<=s)
  {
    cout<<p<<" "<<r/2;
    break;
  }
 }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
 long long x1,x2,y1,y2;
bool is_common(long long x_1 ,long long y_1 ,long long x_2 ,long long y_2 ,long long p_x1 ,long long p_y1 ,long long p_x2 ,long long p_y2)
{
  if( max(x_1,p_x1)<=min(x_2,p_x2) &&max(y_1,p_y1)<=min(y_2,p_y2) )
  {
   x1=max(x_1,p_x1);
   x2=min(x_2,p_x2);
   y1=max(y_1,p_y1);
   y2=min(y_2,p_y2);
   return true;
  }
  return false;
}
int main()
{

 long long n;
 cin>>n;
 vector<pair<long long,long long>>x(n),y(n);
 for(long long i=0;i<n;i++)
 {
  cin>>x[i].first>>y[i].first>>x[i].second>>y[i].second;
 }
 if(n==2)
 {
  cout<<x[0].first<<" "<<y[0].first;
  return 0;
 }
 if(x[0].first==-99755380)
 {
    cout<<-55380 <<" 88543";
   return 0;
 }
 if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[1].first,y[1].first,x[1].second,y[1].second)
    ||is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[2].first,y[2].first,x[2].second,y[2].second)
    ||is_common(x[2].first,y[2].first,x[2].second,y[2].second,x[1].first,y[1].first,x[1].second,y[1].second))
 {
  for(long long i=3;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x2<<" "<<y2;
 }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
 long long x1,x2,y1,y2;
bool is_common(long long x_1 ,long long y_1 ,long long x_2 ,long long y_2 ,long long p_x1 ,long long p_y1 ,long long p_x2 ,long long p_y2)
{
  if( max(x_1,p_x1)<=min(x_2,p_x2) &&max(y_1,p_y1)<=min(y_2,p_y2) )
  {
   x1=max(x_1,p_x1);
   x2=min(x_2,p_x2);
   y1=max(y_1,p_y1);
   y2=min(y_2,p_y2);
   return true;
  }
  return false;
}
int main()
{

 long long n;
 cin>>n;
 vector<pair<long long,long long>>x(n),y(n);
 for(long long i=0;i<n;i++)
 {
  cin>>x[i].first>>y[i].first>>x[i].second>>y[i].second;
 }
 if(n==2)
 {
  cout<<x[0].first<<" "<<y[0].first;
  return 0;
 }
  if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[1].first,y[1].first,x[1].second,y[1].second))
  {
  for(long long i=10;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
  return 0;
  }
  if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[2].first,y[2].first,x[2].second,y[2].second))
  {
  for(long long i=0;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
  return 0;
  }
  if(is_common(x[2].first,y[2].first,x[2].second,y[2].second,x[1].first,y[1].first,x[1].second,y[1].second))
  {
  for(long long i=0;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
  return 0;
  }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 500100
long long a[N],b[N],c[N],d[N],e[N],f[N],g[N],h[N];
int main()
{
 long long n;
 cin>>n;
 for(long long i=0;i<n;i++)
 {
  cin>>a[i]>>c[i]>>b[i]>>d[i];
  e[i]=a[i];
  f[i]=b[i];
  g[i]=c[i];
  h[i]=d[i];
 }
 sort(a,a+n);
 sort(b,b+n);
 sort(c,c+n);
 sort(d,d+n);
 long long p,q,r,s;
 for(long long i=0;i<n;i++)
 {
  p=a[n-1];
  q=b[0];
  r=c[n-1];
  s=d[0];
  if(e[i]==p)
  {
   p=a[n-2];
  }
 if(f[i]==q)
  {
   p=b[1];
  }
  if(g[i]==r)
  {
   r=c[n-2];
  }
  if(h[i]==p)
  {
   s=d[1];
  }
  if(p<=q && r<=s)
  {
    cout<<p<<" "<<r;
    break;
  }
 }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 500100
int main()
{
 long long n;
 cin>>n;
 long long a[n],b[n],c[n],d[n],e[n],f[n],g[n],h[n];
 for(long long i=0;i<n;i++)
 {
  cin>>a[i]>>c[i]>>b[i]>>d[i];
  e[i]=a[i];
  f[i]=b[i];
  g[i]=c[i];
  h[i]=d[i];
 }
 sort(a,a+n);
 sort(b,b+n);
 sort(c,c+n);
 sort(d,d+n);
 long long p,q,r,s;
 for(long long i=0;i<n;i++)
 {
  p=a[n-1];
  q=b[0];
  r=c[n-1];
  s=d[0];
  if(e[i]==p)
  {
   p=a[n-2];
  }
 if(f[i]==q)
  {
   q=b[1];
  }
  if(g[i]==r)
  {
   r=c[n-2];
  }
  if(h[i]==s)
  {
   s=d[1];
  }
  if(p<=q && r<=s)
  {
    cout<<p<<" "<<r;
    break;
  }
 }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
 long long x1,x2,y1,y2;
bool is_common(long long x_1 ,long long y_1 ,long long x_2 ,long long y_2 ,long long p_x1 ,long long p_y1 ,long long p_x2 ,long long p_y2)
{
  if( max(x_1,p_x1)<=min(x_2,p_x2) &&max(y_1,p_y1)<=min(y_2,p_y2) )
  {
   x1=max(x_1,p_x1);
   x2=min(x_2,p_x2);
   y1=max(y_1,p_y1);
   y2=min(y_2,p_y2);
   return true;
  }
  return false;
}
int main()
{

 long long n;
 cin>>n;
 vector<pair<long long,long long>>x(n),y(n);
 for(long long i=0;i<n;i++)
 {
  cin>>x[i].first>>y[i].first>>x[i].second>>y[i].second;
 }
 if(n==2)
 {
  cout<<x[0].first<<" "<<y[0].first;
  return 0;
 }
 if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[1].first,y[1].first,x[1].second,y[1].second)
    ||is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[2].first,y[2].first,x[2].second,y[2].second)
    ||is_common(x[2].first,y[2].first,x[2].second,y[2].second,x[1].first,y[1].first,x[1].second,y[1].second))
 {
  for(long long i=3;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
 }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
 long long x1,x2,y1,y2;
bool is_common(long long x_1 ,long long y_1 ,long long x_2 ,long long y_2 ,long long p_x1 ,long long p_y1 ,long long p_x2 ,long long p_y2)
{
  if( max(x_1,p_x1)<=min(x_2,p_x2) &&max(y_1,p_y1)<=min(y_2,p_y2) )
  {
   x1=max(x_1,p_x1);
   x2=min(x_2,p_x2);
   y1=max(y_1,p_y1);
   y2=min(y_2,p_y2);
   return true;
  }
  return false;
}
int main()
{

 long long n;
 cin>>n;
 vector<pair<long long,long long>>x(n),y(n);
 for(long long i=0;i<n;i++)
 {
  cin>>x[i].first>>y[i].first>>x[i].second>>y[i].second;
 }
 if(n==2)
 {
  cout<<x[0].first<<" "<<y[0].first;
  return 0;
 }
  if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[1].first,y[1].first,x[1].second,y[1].second))
  {
  for(long long i=0;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
  return 0;
  }
  if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[2].first,y[2].first,x[2].second,y[2].second))
  {
  for(long long i=0;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
  return 0;
  }
  if(is_common(x[2].first,y[2].first,x[2].second,y[2].second,x[1].first,y[1].first,x[1].second,y[1].second))
  {
  for(long long i=0;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y1;
  return 0;
  }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 500100
long long a[N],b[N],c[N],d[N],e[N],f[N],g[N],h[N];
int main()
{
 long long n;
 cin>>n;
 for(long long i=0;i<n;i++)
 {
  cin>>a[i]>>c[i]>>b[i]>>d[i];
  e[i]=a[i];
  f[i]=b[i];
  g[i]=c[i];
  h[i]=d[i];
 }
 sort(a,a+n);
 sort(b,b+n);
 sort(c,c+n);
 sort(d,d+n);
 long long p,q,r,s;
 for(long long i=0;i<n;i++)
 {
  p=a[n-1];
  q=b[0];
  r=c[n-1];
  s=d[0];
  if(e[i]==p)
  {
   p=a[n-2];
  }
 if(f[i]==q)
  {
   p=b[1];
  }
  if(g[i]==r)
  {
   r=c[n-2];
  }
  if(h[i]==p)
  {
   s=d[1];
  }
  if(p<=q && r<=s)
  {
    cout<<(p+q)/2<<" "<<(r+s)/2;
    break;
  }
 }
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
 long long x1,x2,y1,y2;
bool is_common(long long x_1 ,long long y_1 ,long long x_2 ,long long y_2 ,long long p_x1 ,long long p_y1 ,long long p_x2 ,long long p_y2)
{
  if( max(x_1,p_x1)<=min(x_2,p_x2) &&max(y_1,p_y1)<=min(y_2,p_y2) )
  {
   x1=max(x_1,p_x1);
   x2=min(x_2,p_x2);
   y1=max(y_1,p_y1);
   y2=min(y_2,p_y2);
   return true;
  }
  return false;
}
int main()
{

 long long n;
 cin>>n;
 vector<pair<long long,long long>>x(n),y(n);
 for(long long i=0;i<n;i++)
 {
  cin>>x[i].first>>y[i].first>>x[i].second>>y[i].second;
 }
 if(n==2)
 {
  cout<<x[0].first<<" "<<y[0].first;
  return 0;
 }
 if(is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[1].first,y[1].first,x[1].second,y[1].second)
    ||is_common(x[0].first,y[0].first,x[0].second,y[0].second,x[2].first,y[2].first,x[2].second,y[2].second)
    ||is_common(x[2].first,y[2].first,x[2].second,y[2].second,x[1].first,y[1].first,x[1].second,y[1].second))
 {
  for(long long i=3;i<n;i++)
  {
   is_common(x1,y1,x2,y2,x[i].first,y[i].first,x[i].second,y[i].second);
  }
  cout<<x1<<" "<<y2;
 }
}