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
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define mini(a,b) a=min(a,(b))
#define maxi(a,b) a=max(a,(b))
#define RE(i,n) for(int i=0,_n=(n);i<_n;++i)
#define RI(i,n) for(int i=1,_n=(n);i<=_n;++i)
const int inf=1e9+5, nax=1e5+5;

int x1[nax], x2[nax], _y1[nax], y2[nax];
int n;
bool jest[nax];
int X1, X2, Y1;

int main()
{
	ios_base::sync_with_stdio(0);
	
	cin >> n;
	RE(i, n) {
		jest[i] = true;
		cin >> x1[i] >> x2[i] >> _y1[i] >> y2[i];
	}
	
	RE(i, n) if(jest[i]) {
		bool zmieniony = true;
		while(zmieniony){
				zmieniony = false;
				RE(j, n) if(jest[j] && i != j) {
					X1 = max(x1[i], x1[j]);
					X2 = min(x2[i], x2[j]);
					if(X1 < X2) {
						Y1 = max(_y1[i], _y1[j]);
						if(Y1 < min(y2[i], y2[j])) {
							jest[j] = false;
							zmieniony = true;
							x1[i] = min(x1[i], x1[j]);
							_y1[i] = min(_y1[i], _y1[j]);
							x2[i] = max(x2[i], x2[j]);
							y2[i] = max(y2[i], y2[j]);
							zmieniony = true;
						}
					}
				}
		}
	}
	vector<pair<pii, pii > > res;
	RE(i, n) if(jest[i]) res.pb(  mp(  mp(x1[i], x2[i]), mp(_y1[i], y2[i])  )  );
	sort(res.begin(), res.end());
	cout << res.size() << "\n";
	RE(i, res.size())
		cout << res[i].st.st << " " << res[i].st.nd << " " << res[i].nd.st << " " << res[i].nd.nd << "\n";
	return 0;
}