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
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pii pair <int, int>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define ppi pair <pii, pii>
#define ppii pair <pii, pii>
#define ppli pair <pli, pli>
#define ppll pair <pli, pll>
using namespace std;

const ll MIN_INF = -(1ll<<61);

template <typename T>
ostream & operator << (ostream &out, const vector <T> &V) {
	if (!V.empty()) {
		out << "{";
		for (auto v : V)
			out << v << ", ";
		out << "\b\b}";			// \b is backspace
	}
	else {
		out << "{}";
	}
	return out;
}

template <class T1, class T2>
ostream & operator << (ostream &out, const pair <T1, T2> &P) {
	out << "{" << P.first << ", " << P.second << "}";
	return out;
}

void testcase_ter() {
    int n, x0, y0;
    cin >> n >> x0 >> y0;
    vector <ppi> P(n); vector <int> X(2*n), Y(2*n);
    for (int i = 0; i < n; i++) {
        cin >> P[i].fi.fi >> P[i].fi.se >> P[i].se.fi >> P[i].se.se;
        X[2*i] = P[i].fi.fi;
        X[2*i+1] = P[i].se.fi;
        Y[2*i] = P[i].fi.se;
        Y[2*i+1] = P[i].se.se;
    }
    vector <int> PX(2 * n, 1), PY(2 * n, 1);
    sort (X.begin(), X.end());
    int ex = unique(X.begin(), X.end()) - X.begin();
    for (int i = 0; i+1 < ex; i++) {
        PX[i] = X[i+1] - X[i];
    }
    PX[ex-1] = x0 - X[ex-1] + X[0];
    sort (Y.begin(), Y.end());
    int ey = unique(Y.begin(), Y.end()) - Y.begin();
    for (int i = 0; i+1 < ey; i++) {
        PY[i] = Y[i+1] - Y[i];
    }
    PY[ey-1] = y0 - Y[ey-1] + Y[0];
    for (int i = 0; i < n; i++) {
        P[i].fi.fi = lower_bound(X.begin(), X.end(), P[i].fi.fi) - X.begin();
        P[i].se.fi = lower_bound(X.begin(), X.end(), P[i].se.fi) - X.begin();
        P[i].fi.se = lower_bound(Y.begin(), Y.end(), P[i].fi.se) - Y.begin();
        P[i].se.se = lower_bound(Y.begin(), Y.end(), P[i].se.se) - Y.begin();
        //cout << P[i] <<endl;
    }
    //cout << PX << "\n" << PY <<endl;
    ll ans = 1;
    unordered_map < string, ll > M;
    
    for (int i = 0; i < ex; i++) {
        for (int j = 0; j < ey; j++) {
            string s;
            for (int k = 0; k < n; k++) {
                int x1 = min(P[k].fi.fi, P[k].se.fi), x2 = max(P[k].fi.fi, P[k].se.fi);
                int y1 = min(P[k].fi.se, P[k].se.se), y2 = max(P[k].fi.se, P[k].se.se);
                int t = 0;
                if (x1 <= i && i < x2) {
                    t += 1;
                }
                if (y1 <= j && j < y2) {
                    t += 2;
                }
                s.push_back('0' + t);
            }
            M[s] += 1ll * PX[i] * PY[j];
            ans = max(ans, M[s]);
        }
    }
    
    cout << ans <<endl;
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    for (int t = 0; t < T; t++) {
        testcase_ter();
    }
    return 0;
}