1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <cstdio>
#include <set>
#include <cmath>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>

#define MP make_pair
#define ST first
#define ND second
#define PII pair<int,int>
#define PPIII pair<PII,int>
#define PPIIPII pair<PII,PII>
#define PIB pair<int,bool>
#define PB push_back
#define VI vector<int>
#define VLI vector<long long>
#define VVLI vector<VLI>
#define VB vector<bool>
#define VPII vector<PII>
#define VPPIII vector<PPIII>
#define VPPIIPII vector<PPIIPII>
#define VPIB vector<PIB>
#define PB push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;


int main()
{
//	ios_base::sync_with_stdio(0);
	int n;
	scanf("%d", &n);

	VPPIIPII v;	//x1 y1 x2 y2

	for(int i=0;i<n;i++)
	{
		int q, w, e, r;
		scanf("%d%d%d%d", &q, &w, &e, &r);
		v.PB(MP(MP(q, e), MP(w, r)));
	}

	sort(v.begin(), v.end());
	for(int i=0;i<n-1;i++)
	if(v[i].ST.ST!=-1)
	{
		bool f;
		do
		{
			f=false;
			for(int j=0;j<n;j++)
			if(v[j].ST.ST!=-1)
			if(j!=i)
			{
				if((max(v[i].ST.ST, v[j].ST.ST)-min(v[i].ND.ST, v[j].ND.ST)) < 0 and (max(v[i].ST.ND, v[j].ST.ND)-min(v[i].ND.ND, v[j].ND.ND)) < 0)
				{
					f=true;
					v[i]=MP(MP(min(v[i].ST.ST, v[j].ST.ST), min(v[i].ST.ND, v[j].ST.ND)), MP(max(v[i].ND.ST, v[j].ND.ST), max(v[i].ND.ND, v[j].ND.ND)));
					v[j]=MP(MP(-1, -1), MP(-1, -1));
				}
			}

		}
		while(f);
	}

	for(int i=0;i<n;i++)
	{
		v[i].ST.ND^=v[i].ND.ST^=v[i].ST.ND^=v[i].ND.ST;
	}

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

	int i=0;
	while(v[i].ST.ST==-1) i++;

	printf("%d\n", n-i);
	for(;i<n;i++)
		printf("%d %d %d %d\n", v[i].ST.ST, v[i].ST.ND, v[i].ND.ST, v[i].ND.ND);



	return 0;
}