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
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i,a,b) for(int i=(a);i<=(b);++i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define SORT(X) sort(X.begin(),X.end())
#define fi first
#define se second


int L[10000000];
vector<pair<pii,pii> > V;
set<pair<pii,pii> > S;

int main () {
  int n;
  scanf("%d",&n);
  FORI(i,n){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    V.pb(mp(mp(a,b),mp(c,d)));
  }
  FOR(i,SZ(V))
    FOR(j,SZ(V))
      if(L[i] == 0 && L[j] == 0 && i!=j) {
	int a = max(V[i].fi.fi,V[j].fi.fi);
	int b = min(V[i].fi.se,V[j].fi.se);
	int c = max(V[i].se.fi,V[j].se.fi);
	int d = min(V[i].se.se,V[j].se.se);
	if((b-a) <= 0 || (d-c) <= 0	) continue;
	L[i] = 1;
	L[j] = 1;
	a = min(V[i].fi.fi,V[j].fi.fi);
	b = max(V[i].fi.se,V[j].fi.se);
	c = min(V[i].se.fi,V[j].se.fi);
	d = max(V[i].se.se,V[j].se.se);
	V.pb(mp(mp(a,b),mp(c,d)));
      }
  FOR(i,SZ(V)) if(L[i] == 0) S.insert(V[i]);
  printf("%d\n",SZ(S));
  FOREACH(it,S) printf("%d %d %d %d\n", it->fi.fi,it->fi.se,it->se.fi,it->se.se);
}