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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#include <bits/stdc++.h>
#include <stdint.h>

using namespace std;


template<class T>
struct SegmentTree {
  size_t n0, n1;
  T v;
  SegmentTree *l;
  SegmentTree *r;
  
  SegmentTree(size_t _n): n0(0), n1(_n), v(), l(NULL), r(NULL) { }
  
  SegmentTree(size_t _n0, size_t _n1): n0(_n0), n1(_n1), v(), l(NULL), r(NULL) { }
  
  ~SegmentTree() {
    delete l; l = NULL;
    delete r; r = NULL;
  }
  
  void add(T const &a, size_t i0, size_t i1) {
    if(i0 <= n0 and n1 <= i1) {
      v += a;
      return;
    }
    
    size_t nh = (n0 + n1) >> 1;
    
    if(i0 < nh) {
      if(l == NULL) l = new SegmentTree(n0, nh);
      l->add(a, i0, min(i1, nh));
    }
    
    if(i1 > nh) {
      if(r == NULL) r = new SegmentTree(nh, n1);
      r->add(a, max(i0, nh), i1);
    }
  }
  
  struct Range {
    size_t n0, n1;
    T v;
    
    Range(): v() { }
    Range(size_t _n0, size_t _n1, T const &_v): n0(_n0), n1(_n1), v(_v) { }
  };
  
  void browse(vector<Range> &out) {
    browse(out, T());
  }
  
  void browse(vector<Range> &out, T pv) {
    pv += v;
    
    if(l == NULL and r == NULL) {
      out.push_back(Range(n0, n1, pv));
    } else {
      size_t nh = (n0 + n1) >> 1;
      
      if(l != NULL) l->browse(out, pv);
      else          out.push_back(Range(n0, nh, pv));
      
      if(r != NULL) r->browse(out, pv);
      else          out.push_back(Range(nh, n1, pv));
    }
  }
};


template<uint32_t M>
struct NumMod {
  uint32_t v;
  
  NumMod(): v(0) { }
  
  NumMod(uint32_t _v): v(_v) { }
  
  operator uint32_t() const { return v; }
  
  NumMod operator+(NumMod<M> const &rhs) const {
    uint64_t t = v;
    t += rhs.v;
    if(t > M) t -= M;
    return t;
  }
  
  NumMod &operator+=(NumMod<M> const &rhs) {
    uint64_t t = v;
    t += rhs.v;
    if(t > M) t -= M;
    v = t;
    return *this;
  }
  
  NumMod operator-(NumMod<M> const &rhs) const {
    uint64_t t = v;
    t += M;
    t -= rhs.v;
    if(t > M) t -= M;
    return t;
  }
  
  NumMod operator*(NumMod<M> const &rhs) const {
    uint64_t t = v;
    t *= rhs.v;
    return t % M;
  }
  
  size_t get_hash() const {
    return hash<uint32_t>()(v);
  }
  
};

template<class T1, class T2>
struct ArithmeticPair {
  T1 v1;
  T2 v2;
  
  ArithmeticPair(): v1(), v2() { }
  ArithmeticPair(T1 const &_v1, T2 const &_v2): v1(_v1), v2(_v2) { }
  
  ArithmeticPair operator+(ArithmeticPair<T1, T2> const &rhs) const {
    return ArithmeticPair<T1, T2>(v1 + rhs.v1, v2 + rhs.v2);
  }
  
  ArithmeticPair &operator+=(ArithmeticPair<T1, T2> const &rhs) {
    v1 += rhs.v1;
    v2 += rhs.v2;
    return *this;
  }
  
  ArithmeticPair operator-(ArithmeticPair<T1, T2> const &rhs) const {
    return ArithmeticPair<T1, T2>(v1 - rhs.v1, v2 - rhs.v2);
  }
  
  ArithmeticPair operator*(ArithmeticPair<T1, T2> const &rhs) const {
    return ArithmeticPair<T1, T2>(v1 * rhs.v1, v2 * rhs.v2);
  }
  
  bool operator==(ArithmeticPair<T1, T2> const &rhs) const {
    return (v1 == rhs.v1 and v2 == rhs.v2);
  }
  
  size_t get_hash() const {
    return v1.get_hash() ^ (v2.get_hash() + 0x5555555555555555);
  }
  
  struct hash {
    size_t operator()(ArithmeticPair<T1, T2> const &ap) const { return ap.get_hash(); }
  };
};


#define P 1082150203
#define Q 1652000893


typedef ArithmeticPair< NumMod<P>, NumMod<Q> > Key;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, X, Y;
  cin >> n >> X >> Y;
  
  SegmentTree<Key> stx(X);
  SegmentTree<Key> sty(Y);
  
  Key base(17, 37);
  Key v(1, 1);
  
  for(int i = 0; i < n; i++) {
    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    
    if(x1 < x0) swap(x0, x1);
    if(y1 < y0) swap(y0, y1);
    
    x0--; x1--; y0--; y1--;
    
    v = v * base;
    
    stx.add(v, x0, x1);
    sty.add(v, y0, y1);
  }
  
  unordered_map<Key, uint64_t, Key::hash> mx;
  unordered_map<Key, uint64_t, Key::hash> my;
  
  vector< SegmentTree<Key>::Range > bx;
  vector< SegmentTree<Key>::Range > by;
  
  stx.browse(bx);
  sty.browse(by);
  
  for(size_t i = 0; i < bx.size(); i++) {
    mx[bx[i].v] += bx[i].n1 - bx[i].n0;
  }
  
  for(size_t i = 0; i < by.size(); i++) {
    my[by[i].v] += by[i].n1 - by[i].n0;
  }
  
  uint64_t xmax = 0, ymax = 0;
  
  for(unordered_map<Key, uint64_t, Key::hash>::const_iterator it = mx.begin(); it != mx.end(); it++) {
    xmax = max(xmax, it->second);
  }
  
  for(unordered_map<Key, uint64_t, Key::hash>::const_iterator it = my.begin(); it != my.end(); it++) {
    ymax = max(ymax, it->second);
  }
  
  cout << xmax * ymax << '\n';
  
  return 0;
}