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
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

//long long P=1000000000039L;
//long long P=67280421310721L;
long long P=999999937;
//long long P=100000037;
//long long P=1000000009;
//99999959 | 99999971 | 99999989 | 100000007 | 100000037
//long long P[]={999999999959L,999999999961L,999999999989L,1000000000039L,1000000000061};
vector<long long> VV;

void prep(int n) {
    VV.resize(n);
	long long w = 1;
	for (int i=0;i<n;i++) {
		VV[i]=w;
		w=(w*3+1)%P;
	}
	//for (auto &it:v)cout << it<<" ";
}


int longest(vector<pair<int, long long> > &v) {
	map<long long, int> s;
	int w=0,p=0,m=0;
	for (vector<pair<int, long long> >::iterator it=v.begin();it!=v.end();it++) {
		int k = s[w] + (it->first-p);
		s[w] = k;
		if (k>m) m = k;
		p = it->first;
		if (it->second<0)
            w = (w+P-VV[-it->second])%P;
        else
            w = (w+VV[it->second])%P;
	}
	//for (auto &it:s) cout << it.first << " " << it.second << endl;
	return m;
}


int main() {
	ios_base::sync_with_stdio(0);
	int n,X,Y;
	cin >> n >> X >> Y;
	prep(n+1);
	vector<pair<int, long long> > ver,hor;
	for (int i=1;i<=n;i++) {
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if (x1>x2) swap(x1,x2);
		if (y1>y2) swap(y1,y2);
		//cout << x1 <<" "<<y1<<" "<<x2<<" "<<y2<<endl;
		ver.push_back(make_pair(y1,i));
		ver.push_back(make_pair(y2,-i));
		hor.push_back(make_pair(x1,i));
		hor.push_back(make_pair(x2,-i));
	}
	ver.push_back(make_pair(Y,0));
	hor.push_back(make_pair(X,0));
	sort(ver.begin(),ver.end());
	sort(hor.begin(),hor.end());
	//for (auto &it:hor) cout << it.first<<" "<<it.second<<endl;
	long long h = longest(ver);
	long long w = longest(hor);
	cout << h*w << endl;
	//cout <<h << endl << w << endl;
	return 0;
}