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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include <bits/stdc++.h>
using namespace std;
struct ractangle{
    long long x1;
    long long y1;
    long long x2;
    long long y2;
    long long ha;
};
vector<long long> rx;
vector<long long> ry;
bool acompare(ractangle a,ractangle b) { return a.ha < b.ha; }
bool acompare2(ractangle a,ractangle b) { return a.x1 < b.x1; }
long long ha = 101;
long long  MOD = 1000000007LL;

ractangle P1[4500010];long long p1s=0;
ractangle V[45010];
ractangle Vt[45010];
long long H[9] = {1,2,2,3,3,4,4,4,4};
int main() {
    long long n,x1,x2,y1,y2;
    long long X, Y;
    cin>>n>>X>>Y;
    for(long long i =0;i<n;i++){
        cin>>x1>>y1>>x2>>y2;
        if(x1>x2)swap(x1,x2);
        if(y1>y2)swap(y1,y2);
        rx.push_back(x1);
        rx.push_back(x2);
        ry.push_back(y1);
        ry.push_back(y2);
        
        P1[p1s].x1 = x1;
        P1[p1s].y1 = y1;
        P1[p1s].x2 = x2;
        P1[p1s].y2 = y2;
        p1s++;

        P1[p1s].x1 = 0;
        P1[p1s].y1 = y1;
        P1[p1s].x2 = x1;
        P1[p1s].y2 = y2;
        p1s++;
        P1[p1s].x1 = x2;
        P1[p1s].y1 = y1;
        P1[p1s].x2 = X;
        P1[p1s].y2 = y2;
        p1s++;

        P1[p1s].x1 = x1;
        P1[p1s].y1 = y2;
        P1[p1s].x2 = x2;
        P1[p1s].y2 = Y;
        p1s++;

        P1[p1s].x1 = x1;
        P1[p1s].y1 = 0;
        P1[p1s].x2 = x2;
        P1[p1s].y2 = y1;
        p1s++;

        //
        P1[p1s].x1 = 0;
        P1[p1s].y1 = y2;
        P1[p1s].x2 = x1;
        P1[p1s].y2 = Y;
        p1s++;

        P1[p1s].x1 = x2;
        P1[p1s].y1 = y2;
        P1[p1s].x2 = X;
        P1[p1s].y2 = Y;
        p1s++;

        P1[p1s].x1 = 0;
        P1[p1s].y1 = 0;
        P1[p1s].x2 = x1;
        P1[p1s].y2 = y1;
        p1s++;

        P1[p1s].x1 = x2;
        P1[p1s].y1 = 0;
        P1[p1s].x2 = X;
        P1[p1s].y2 = y1;
        p1s++;
    }
    //max racangle

    rx.push_back(X);
    ry.push_back(Y);
    sort(rx.begin(),rx.end());
    sort(ry.begin(),ry.end());
    long long cx = 0,cy=0,mx = 0,my = 0;
    for(long long i =0;i<rx.size();i++){
        if(cx!=rx[i]){
            if(mx<rx[i]-cx){
                mx=rx[i]-cx;
            }
            cx = rx[i];
        }
        if(cy!=ry[i]){
            if(my<ry[i]-cy){
                my=ry[i]-cy;
            }
            cy = ry[i];
        }
    }
    long long max_pro = mx*my;
  //  cout<<"MAX PROSTOKAT: "<<mx*my<<"\n";
  //  int yy;cin>>yy;

    long long vs = 9;
    for( long long i = 0 ; i<9;i++){
        V[i].x1 = P1[i].x1;
        V[i].y1 = P1[i].y1;
        V[i].x2 = P1[i].x2;
        V[i].y2 = P1[i].y2;
        V[i].ha = H[i];
    }
    long long mvts = 0;
    for(long long i = 1; i<n;i++){
        long long vts = 0;
        for(long long k = 0;k<vs;k++){
            for(long long j = 0;j<9;j++){
                long long x1 = max(V[k].x1, P1[i*9+j].x1);
                long long y1 = max(V[k].y1, P1[i*9+j].y1);
                long long x2 = min(V[k].x2, P1[i*9+j].x2);
                long long y2 = min(V[k].y2, P1[i*9+j].y2);
                if(x1<x2 && y1<y2){
                    Vt[vts].x1 = x1;
                    Vt[vts].y1 = y1;
                    Vt[vts].x2 = x2;
                    Vt[vts].y2 = y2;
                    Vt[vts].ha = (V[k].ha*ha + H[j])%MOD;
                    
                    vts++;
                }
                
            }
        }
        //redukuj


        vs = 0;
        if(vts > 0) {
            long long cha = Vt[0].ha;
            long long ile = 0;
            sort(Vt,Vt+vts,acompare);
            long long cpole = 0;
            for(long long i = 0; i <vts;i++){
                
                if(cha != Vt[i].ha ){
                    if(cpole < max_pro){
                        vs-=ile;
                    }
                    ile = 0;
                    cha = Vt[i].ha;
                    cpole = (Vt[i].x2 - Vt[i].x1)*(Vt[i].y2 - Vt[i].y1);
                }else{
                    cpole += (Vt[i].x2 - Vt[i].x1)*(Vt[i].y2 - Vt[i].y1);
                }

                V[vs].x1 = Vt[i].x1;
                V[vs].y1 = Vt[i].y1;
                V[vs].x2 = Vt[i].x2;
                V[vs].y2 = Vt[i].y2;
                V[vs].ha = Vt[i].ha;
                vs++;
                ile++;
            }
        }
       
        if(vts > mvts){
            mvts = vts;
            //cout<<"vts: "<<vts<<"\n";
        }

        if(vts>10000){
            cout<<max_pro<<"\n";
            return 0;
        }

        
        //vs = vts;
    }
    long long pole = 0;
    
    sort(V,V+vs,acompare);
    long long cha = -1;
    long long cpole = 0;
    for(long long i = 0;i<vs;i++){
        if(cha != V[i].ha ){
            if(pole < cpole){
                pole = cpole;
            }
            cha = V[i].ha;
            cpole = (V[i].x2 - V[i].x1)*(V[i].y2 - V[i].y1);
        }else{
            cpole += (V[i].x2 - V[i].x1)*(V[i].y2 - V[i].y1);
        }
    }
    if(pole < cpole){
        pole = cpole;
    }
    cout<<pole<<"\n";
    return 0;
}