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
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

struct ter {
	int left, right, up, down;
};

long long max(long long a, long long b) {
	if (a > b) return a;
	return b;
}

long long reservate(vector <vector < int > > pole, ter specimen[], int n, int xx, int yy, int current) {

	long long max_ar = 0;

	if (current == n) {
		for (int y = yy - 1; y >= 0; y--) {
			for (int x = 0; x < xx; x++) {
				if (pole[y][x] == n) {
					max_ar++;
				}
			}
		}
		return max_ar;
	}
	else {

		vector <vector <int> > a = pole;
		vector <vector <int> > b = pole;
		vector <vector <int> > c = pole;
		vector <vector <int> > d = pole;


		long long ar_a;
		long long ar_b;
		long long ar_c;
		long long ar_d;

		for (int y = yy - 1; y >= 0; y--) {
			for (int x = 0; x < xx; x++) {
				if (x >= specimen[current].left && x < specimen[current].right && y >= specimen[current].down && y < specimen[current].up) {
					a[y][x]++;
				}
			}
		}

		ar_a = reservate(a, specimen, n, xx, yy, current + 1);

		for (int y = yy - 1; y >= 0; y--) {
			for (int x = 0; x < xx; x++) {
				if ((x < specimen[current].left || x >= specimen[current].right) && (y < specimen[current].down || y >= specimen[current].up)) {
					b[y][x]++;
				}
			}
		}

		ar_b = reservate(b, specimen, n, xx, yy, current + 1);

		for (int y = yy - 1; y >= 0; y--) {
			for (int x = 0; x < xx; x++) {
				if (x >= specimen[current].left && x < specimen[current].right && (y < specimen[current].down || y >= specimen[current].up)) {
					c[y][x]++;
				}
			}
		}

		ar_c = reservate(c, specimen, n, xx, yy, current + 1);

		for (int y = yy - 1; y >= 0; y--) {
			for (int x = 0; x < xx; x++) {
				if ((x < specimen[current].left || x >= specimen[current].right) && y >= specimen[current].down && y < specimen[current].up) {
					d[y][x]++;
				}
			}
		}

		ar_d = reservate(d, specimen, n, xx, yy, current + 1);

		max_ar = max(ar_a, max(ar_b, max(ar_c, ar_d)));

		return max_ar;
	}


}

int main() {
	int n, xx, yy;
	scanf("%d%d%d", &n, &xx, &yy);

	vector <vector<int> > pole;

	for (int y = yy - 1; y >= 0; y--) {
		vector<int> row;
		for (int x = 0; x < xx; x++) {
			row.push_back(0);
		}
		pole.push_back(row);
	}

	ter *specimen = new ter[n];

	for (int i = 0; i < n; i++) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		if (x1 < x2) {
			specimen[i].left = x1;
			specimen[i].right = x2;
		}
		else {
			specimen[i].right = x1;
			specimen[i].left = x2;
		}
		if (y1 > y2) {
			specimen[i].up = y1;
			specimen[i].down = y2;
		}
		else {
			specimen[i].down = y1;
			specimen[i].up = y2;
		}
	}

	cout << reservate(pole, specimen, n, xx, yy, 0);

}