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
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define klar(v) memset(v, 0, sizeof(v))
#define bust ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a, b) __gcd(a, b);
#define debug(x) cout << #x << " " << x << endl;
#define endl "\n"

typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const int maxn = 5e5+100;

bool testCase();

struct rect{
	pii l, r;
};

int X, Y, n;
ll ans = 0;

vector <rect> vec;
vi mem;
vll answers;
int bplane[1234][1234];

bool cmp(const rect& a, const rect& b){
	if(a.l.st != b.l.st) return a.l.st < b.l.st;
	if(a.l.nd != b.l.nd) return a.l.nd < b.l.nd;
	if(a.r.st != b.r.st) return a.r.st < b.r.st;
	if(a.r.nd != b.r.nd) return a.r.nd < b.r.nd;
	return false;
}

vector <rect> trans_rec(rect x, int mode){
	vector <rect> ret;
	switch(mode){
		case 0:
			ret.pb(x);
			break;
		case 1:
			ret.pb({
				{ x.l.st, 1 },
				{ x.r.st, x.l.nd-1 }
			});
			ret.pb({
				{ x.l.st, x.r.nd+1 },
				{ x.r.st, Y }
			});
			break;
		case 2:
			ret.pb({
				{ 1, x.l.nd },
				{ x.l.st - 1, x.r.nd }
			});
			ret.pb({
				{ x.r.st + 1, x.l.nd },
				{ X, x.r.nd }
			});
			break;
		case 3:
			ret.pb({
				{ 1, 1 },
				{ x.l.st - 1, x.l.nd - 1 }
			});
			ret.pb({
				{ 1, x.r.nd + 1 },
				{ x.l.st - 1, Y }
			});
			ret.pb({
				{ x.r.st + 1, x.r.nd + 1},
				{ X, Y }
			});
			ret.pb({
				{ x.r.st + 1, 1 },
				{ X, x.l.nd - 1 }
			});
			break;
	}
	return ret;
}

ll ssingle(rect x){
	return 1LL * (x.r.st - x.l.st + 1) * ( x.r.nd - x.l.nd + 1);
}

ll size(rect x, int mode){
	ll ret = 0;
	vector <rect> plane;
	plane = trans_rec(x, mode);
	for(auto i: plane){
		ret += ssingle(i);
	}
	return ret;
}

ll plane_ans(vector <rect> plane){
	klar(bplane);
	ll ans = 0;
	for(int i = 0; i < plane.size(); i++){
        rect a = plane[i];
        bplane[a.l.nd][a.l.st] += 1;
        bplane[a.l.nd][a.r.st+1] -= 1;
        bplane[a.r.nd+1][a.l.st] -= 1;
        bplane[a.r.nd+1][a.r.st+1] += 1;
    }
    for(int i = 1; i <= Y; i++){
        for(int j = 1; j <= X; j++){
            if(i - 1 >= 0)
                bplane[i][j] += bplane[i-1][j];
            if(j - 1 >= 0)
                bplane[i][j] += bplane[i][j-1];
            if(i - 1 >= 0 && j - 1 >= 0)
                bplane[i][j] -= bplane[i-1][j-1];
            if(bplane[i][j] == n)
                ans++;
        }
    }
    /* for(int i = 1; i <= Y; i++){ */
    /*     for(int j = 1; j <= X; j++){ */
    /*         cout << bplane[i][j] << " "; */
    /*     } */
    /*     cout << endl; */
    /* } */
	/* cout << ans << endl; */
    return ans;
}

void back(int depth, vector<int> modes){
	if(depth == n){
		vector <rect> tempr, plane;
		for(int i = 0; i < n; i++){
			tempr = trans_rec(vec[i], modes[i]);
			for(auto j: tempr)
				plane.pb(j);
		}
		ll gans = plane_ans(plane);
		ans = max(ans, gans);
		return;
	}
	for(int i = 0; i < 4; i++){
		modes.pb(i);
		back(depth+1, modes);
		modes.pop_back();
	}
}


int main(){
	cin >> n >> X >> Y;
	for(int i = 0; i < n; i++){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if(a > c) swap(a, c);
		if(b > d) swap(b, d);
		vec.pb({
			{ a + 1, b + 1 },
			{ c, d }
		});
	}
	vector <int> modes;
	back(0, modes);
    cout << ans << endl;
}