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
#include <bits/stdc++.h>

using namespace std;

class segtree {
  struct node {
    int val;
    int cnt;
    int off;

    void apply(int v) {
      val += v;
      off += v;
    }
  };

  vector<node> tree;
  vector<int> d;
  int n;

  node unite(const node& l, const node& r) {
    node res;
    res.val = max(l.val, r.val);
    res.cnt = (res.val == l.val ? l.cnt : 0) + (res.val == r.val ? r.cnt : 0);
    res.off = 0;
    return res;
  }

  void pull(int x, int z) {
    tree[x] = unite(tree[x + 1], tree[z]);
  }

  void push(int x, int z) {
    if (tree[x].off) {
      tree[x + 1].apply(tree[x].off);
      tree[z].apply(tree[x].off);
      tree[x].off = 0;
    }
  }

  void build(int x, int l, int r) {
    if (l == r - 1) {
      tree[x].val = 0;
      tree[x].cnt = d[r] - d[l];
      tree[x].off = 0;
    } else {
      int y = (l + r) >> 1, z = x + ((y - l) << 1);
      build(x + 1, l, y);
      build(z, y, r);
      pull(x, z);
    }
  }

  void modify(int x, int l, int r, int ll, int rr, int v) {
    if (ll <= l && r <= rr) {
      tree[x].apply(v);
    } else {
      int y = (l + r) >> 1, z = x + ((y - l) << 1);
      push(x, z);
      if (ll < y) {
        modify(x + 1, l, y, ll, rr, v);
      }
      if (rr > y) {
        modify(z, y, r, ll, rr, v);
      }
      pull(x, z);
    }
  }

 public:
  segtree(vector<int> d) : d(d) {
    n = d.size() - 1;
    tree.resize(2 * n - 1);
    build(0, 0, n);
  }

  void modify(int ll, int rr, int v) {
    if (ll != rr) {
      modify(0, 0, n, ll, rr, v);
    }
  }

  node query() {
    return tree[0];
  }
};

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  vector<pair<int, int>> xx(n);
  vector<pair<int, int>> yy(n);
  for (int i = 0; i < n; ++i) {
    cin >> xx[i].first >> yy[i].first;
    cin >> xx[i].second >> yy[i].second;
  }
  auto solve = [&](vector<pair<int, int>> a, int m) {
    vector<int> d;
    for (int i = 0; i < n; ++i) {
      d.push_back(a[i].first);
      d.push_back(a[i].second);
      if (a[i].first > a[i].second) {
        swap(a[i].first, a[i].second);
      }
    }
    d.push_back(0);
    d.push_back(m);
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    vector<vector<pair<int, int>>> ev(d.size());
    segtree seg(d);
    for (auto p : a) {
      p.first = lower_bound(d.begin(), d.end(), p.first) - d.begin();
      p.second = lower_bound(d.begin(), d.end(), p.second) - d.begin();
      ev[p.first].push_back(p);
      ev[p.second].push_back(p);
      seg.modify(0, p.first, 1);
      seg.modify(p.second, d.size() - 1, 1);
    }
    int ans = 0;
    for (int i = 0; i < (int) d.size(); ++i) {
      for (auto p : ev[i]) {
        if (p.first == i) {
          seg.modify(0, p.first, -1);
          seg.modify(p.first, p.second, 1);
          seg.modify(p.second, d.size() - 1, -1);
        } else {
          seg.modify(0, p.first, 1);
          seg.modify(p.first, p.second, -1);
          seg.modify(p.second, d.size() - 1, 1);
        }
      }
      if (seg.query().val == n) {
        ans = max(ans, seg.query().cnt);
      }
    }
    return ans;
  };
  cout << (long long) solve(xx, x) * solve(yy, y) << "\n";
  return 0;
}