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
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define speed ios::sync_with_stdio(false);cin.tie();cout.tie();
//#define int long long
//const int mod=1000000007;
//const int mod=1000003;
const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.0000000001;
using namespace std;
pii X[500005],Y[500005],A[500005];
int n;
bool cmp(pii a,pii b)
{
    if(a.st!=b.st)
        return a.st<b.st;
    return a.nd>b.nd;
}
struct liczba
{
    int a,b,w;
};
vector<liczba> stos;
set<int> S;
int funkcja()
{
    sort(A+1,A+n+1,cmp);
    int wynik=0;
	S.insert(1);
    for(int i=1; i<=n; i++)
    {
	S.insert(-A[i].nd);
        while(!stos.empty()&&A[i].st>=stos.back().b)
        {
            int a=stos.back().a,b=stos.back().b;
            wynik=max(wynik,stos.back().w);
            stos.pop_back();
		if(b>stos.back().b)
		{
			//stos.back().w+=b-stos.back().b;
			stos.back().b=b;
		}
            stos.back().w-=(b-a);
        }
        if(!stos.empty()&&stos.back().b<A[i].nd)
        {
            //stos.back().w+=A[i].nd-stos.back().b;
            swap(stos.back().b,A[i].nd);
        }
	auto it=S.upper_bound(-A[i].nd);
	int x=-(*it);
	//cout<<A[i].st<<" "<<A[i].nd<<" "<<x<<endl;
        stos.pb({A[i].st,A[i].nd,A[i].nd-max(x,A[i].st)});
    }
    while(!stos.empty())
    {
            int a=stos.back().a,b=stos.back().b;
            wynik=max(wynik,stos.back().w);
            stos.pop_back();
	if(stos.empty())
		break;
		if(b>stos.back().b)
		{
			//stos.back().w+=b-stos.back().b;
			stos.back().b=b;
		}
	
            stos.back().w-=(b-a);
    }
S.clear();
    return wynik;
}
int main()
{
    speed
    int w1,w2;
    cin>>n>>w1>>w2;
    for(int i=1; i<=n; i++)
    {
        cin>>X[i].st>>Y[i].st>>X[i].nd>>Y[i].nd;
        if(X[i].st>X[i].nd)
            swap(X[i].st,X[i].nd);
        if(Y[i].st>Y[i].nd)
            swap(Y[i].st,Y[i].nd);
    }
    n++;
    X[n]=mp(0,w1);
    Y[n]=mp(0,w2);
    for(int i=1; i<=n; i++)
        A[i]=X[i];
    int x=funkcja();
    for(int i=1; i<=n; i++)
        A[i]=Y[i];
    int y=funkcja();
	//cout<<x<<" "<<y<<endl;
    cout<<(ll)x*y;
    return 0;
}