#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#include <string>
using namespace std;
typedef long long LL;
typedef pair<int,int> PI;
#define MP make_pair
#define PB push_back
#define SD second
#define FT first

int k,n,m,q;

const int N = 100003;
const int INF = 20000000;

struct Prost : pair<PI,PI>
{
	PI punkt1;
	PI punkt2;
	PI punkt3;
	PI punkt4;
	Prost() {}
	Prost(int x1, int x2, int y1, int y2) {
		FT.FT=min(x1,x2);
		FT.SD=max(x1,x2);
		SD.FT=min(y1,y2);
		SD.SD=max(y1,y2);
		punkt1 = MP(FT.FT,SD.FT);
		punkt2 = MP(FT.SD,SD.SD);
		punkt3 = MP(FT.FT,SD.SD);
		punkt4 = MP(FT.SD,SD.FT);
	}
	
	int x1() {return FT.FT;}
	int x2() {return FT.SD;}
	int y1() {return SD.FT;}
	int y2() {return SD.SD;}
	
	bool przecina(Prost &b) {
		return ( (x1() < b.x2() && x2() > b.x1() &&
				   y1() < b.y2() && y2() > b.y1() ));
		//return b.zawiera(punkt1) || b.zawiera(punkt2) || b.zawiera(punkt3) || b.zawiera(punkt4) || zawiera(b.punkt1) || zawiera(b.punkt2) || zawiera(b.punkt3) || zawiera(b.punkt4);
	}
	
	bool zawiera(PI punkt) {
		return FT.FT < punkt.FT && punkt.FT < FT.SD && SD.FT < punkt.SD && punkt.SD < SD.SD;
	}
	
	Prost polacz(Prost &b) {
		return Prost(min(x1(),b.x1()),max(x2(),b.x2()),min(y1(),b.y1()),max(y2(),b.y2()));
	}
	
	string toString() {
		char res[100];
		sprintf(res,"%d %d %d %d",FT.FT,FT.SD,SD.FT,SD.SD);
		return res;
	}
};

list<Prost> plem;
typedef list<Prost>::iterator it;

void polacz(list<Prost> &plem, Prost nowe) {
	int cykl = 1;
	// O(n) amortyzuje siê?
	while(cykl) {
		cykl = 0;
		for(it p=plem.begin();p!=plem.end();p++) {
			if(nowe.przecina(*p)) {
				nowe = nowe.polacz(*p);
				it usun = p;
				p++;
				plem.erase(usun);
				p--;
				cykl = 1;
			}
		}
	}
	plem.PB(nowe);
}

int main() {
	scanf("%d",&n);
	// O(n^2);
	for(int i=0;i<n;i++) {
		int x1,x2,y1,y2;
		scanf("%d%d%d%d",&x1,&x2,&y1,&y2);
		Prost nowe = Prost(x1,x2,y1,y2);
		polacz(plem,nowe);
	}
	
	vector<Prost>panstwa = vector<Prost>(plem.begin(),plem.end());
	sort(panstwa.begin(),panstwa.end());
	printf("%d\n", panstwa.size());
	for(int i=0;i<panstwa.size();i++) {
		printf("%s\n", panstwa[i].toString().c_str());
	}
		
	return 0;
}
