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
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, n) for(auto &i : n)
#define SZ(x) (int)(x).size()
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

const int MOD = 1000000007;
const int p1 = 31, p2 = 181, p3 = 997;
VI P1, P2, P3;

void calcp(int n){
	P1.reserve(n);
	P2.reserve(n);
	P3.reserve(n);
	P1.push_back(1);
	P2.push_back(1);
	P3.push_back(1);
	FOR(i, n) P1.push_back((1ll*p1*P1.back())%MOD),
			P2.push_back((1ll*p2*P2.back())%MOD),
			P3.push_back((1ll*p3*P3.back())%MOD);
}

inline void change(int &a, int add, int sign){
	if(sign == 1){
		a = a+add;
		if(a >= MOD) a -= MOD;
	}else{
		a = a-add;
		if(a < 0) a += MOD;
	}
}

int calc(std::vector<PII> &A, int upto){
	std::random_shuffle(A.begin(), A.end());
	int n = SZ(A);
	std::map<PR<int, PII>, int> map;
	std::vector<PR<int, PII> > ev;
	FOR(i, n){
		ev.push_back(MP(A[i].X, MP(i, 1)));
		ev.push_back(MP(A[i].Y+1, MP(i, -1)));
	}
	ev.push_back(MP(upto, MP(-1, -1)));
	std::sort(ev.begin(), ev.end());
	PR<int, PII> hash = MP(0, MP(0, 0));
	int last = 0;
	int max = 0;
	TRAV(pr, ev){
		if(pr.X != last){
			map[hash] += pr.X-last;
			max = std::max(max, map[hash]);
			last = pr.X;
		}
		if(pr.Y.X != -1){
			change(hash.X, P1[pr.Y.X], pr.Y.Y);
			change(hash.Y.X, P2[pr.Y.X], pr.Y.Y);
			change(hash.Y.Y, P3[pr.Y.X], pr.Y.Y);
		}
	}
	return max;
}

int main(){
	std::vector<PII> A, B;
	int n, X, Y;
	std::scanf("%d%d%d", &n, &X, &Y);
	calcp(n);
	FOR(i, n){
		int x1, y1, x2, y2;
		std::scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		if(x1 > x2) std::swap(x1, x2);
		if(y1 > y2) std::swap(y1, y2);
		A.push_back(MP(x1, x2-1));
		B.push_back(MP(y1, y2-1));
	}
	std::printf("%lld\n", 1ll*calc(A, X)*calc(B, Y));
	return 0;
}