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

void check(int &x, int &y)
{
	if(x > y)
		swap(x, y);
}

void in(vector<vector<int>> &v ,int X, int Y, int x1, int y1, int x2, int y2)
{
	for (int x = 0; x < X; ++x)
	{
		for (int y = 0; y < Y; ++y)
		{
			if(x1 <= x && x < x2)
			{
				if(y1 <= y && y < y2)
					v[x][y] += 1;
				
			}
		}
	}
}


void out(vector<vector<int>> &v , int X, int Y, int x1, int y1, int x2, int y2)
{
	for (int x = 0; x < X; ++x)
	{
		for (int y = 0; y < Y; ++y)
		{
			if(x1 > x || x >= x2)
			{
				if(y1 > y || y >= y2)
					v[x][y] += 1;
				
			}
		}
	}
}


void up(vector<vector<int>> &v, int X, int Y, int x1, int y1, int x2, int y2)
{
	for (int x = 0; x < X; ++x)
	{
		for (int y = 0; y < Y; ++y)
		{
			bool help = (y1 > y || y >= y2) && (x1 <= x && x < x2);
			if(x1 <= x && x < x2)
			{
				if(y1 > y || y >= y2) 
					v[x][y] += 1;
			}
		}
	}
}


void left(vector<vector<int>> &v, int X, int Y, int x1, int y1, int x2, int y2)
{
	for (int x = 0; x < X; ++x)
	{
		for (int y = 0; y < Y; ++y)
		{
			if(x1 > x || x >= x2)
			{
				if(y1 <= y && y < y2)
					v[x][y] += 1;
			}	
		}
	}
}



int main()
{
	int n, X, Y;
	cin >> n >> X >> Y;
	vector<vector<int>> v(X, vector<int>(Y, 0));
	for (int i = 0; i < n; ++i)
	{
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
	
		check(x1, x2);
		check(y1, y2);
		

		int left_p = (y2 - y1) * (x1 + X-x2);
		int up_p = (x2 - x1) * (y1 + Y- y2);
		int in_p = (x2 -x1) * (y2- y1);
		int out_p = X*Y - (left_p + up_p + in_p);


		int p = 0;
		int max = left_p;
		if(up_p > max) 
		{
			max = up_p;
			p = 1;
		}
		if(in_p > max) 
		{
			max = in_p;
			p = 2;
		}
		if(out_p > max) 
		{
			max = out_p;
			p = 3;
		}

		switch(p)
		{
			case 0:
				left(v, X, Y, x1, y1, x2, y2);
				break;
			case 1:
				up(v, X, Y, x1, y1, x2, y2);
				break;
			case 2:
				in(v, X, Y, x1, y1, x2, y2);
				break;
			case 3:
				out(v, X, Y, x1, y1, x2, y2);
				break;
		}
	}

	int wynik=0;
	for (int x = 0; x < X; ++x)
	{
		for (int y = 0; y < Y; ++y)
		{
			if(v[x][y] == n)
				wynik++;
			
		}
	}
	cout << wynik << endl;
}