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

using namespace std;
int n, m, q;

bool black[2005][20005];
bool used[2005][2005];
bool up_pref[2005][2005];

long long up[2005];
long long r[2005];

long long pr_up[2005];
long long pr_r[2005];

const long long M = 1000000007;

long long ans(){

	for (int i = 0; i < n; ++i)
	{
		up[i] = r[i] = 0;
	}

	for (int y = n - 1; y >= 0; --y)
	{
		for (int x = n - 1; x >= 0; --x)
		{
			up[x] += black[x][y];
			r[y] += black[x][y];
		}
	}


	//cout << endl;

	sort(up, up + n);
	sort(r, r + n);

	for (int i = 0; i < n; ++i)
	{
		//cout << up[i] << " ";
		pr_r[i + 1] = pr_r[i] + r[i];
		pr_up[i + 1] = pr_up[i] + up[i];
	}


	long long maximum = -M;

	/*for (int i = 0; i < n; ++i)
	{
		cout << pr_r[i] << " ";
	}
	cout << endl;
	for (int i = 0; i < n; ++i)
	{
		cout << pr_up[i] << " ";
	}
	cout << endl;*/

	for (long long a = 0; a <= n; ++a)
	{
		for (long long b = 0; b <= n; ++b)
		{
			//cout << a << " " << b << " " << maximum << endl;
			maximum = max(maximum, (long long) (a * b - pr_up[a] - pr_r[b]));
		}
	}
	//cout << endl;
	long long total_black = pr_up[n];
	long long total_white = n * n - pr_up[n];
	//cout << "total_white = " << total_white << " total_black = " << total_black << endl;
	return total_white - maximum;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> q;

	for (int i = 0; i < m; ++i)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1--;
		x2--;
		y1--;
		y2--;
		used[x2][y2] = !used[x2][y2];
		if(x1 > 0){
			used[x1 - 1][y2] = !used[x1 - 1][y2];
		}
		if(y1 > 0){
			used[x2][y1 - 1] = !used[x2][y1 - 1];
		}
		if(y1 > 0 and x1 > 0){
			used[x1 - 1][y1 - 1] = !used[x1 - 1][y1 - 1];
		}
	}

	for (int y = n - 1; y >= 0; --y)
	{
		black[n - 1][y] = used[n - 1][y] xor black[n - 1][y + 1];
		for (int x = n - 2; x >= 0; --x)
		{
			up_pref[x][y] = up_pref[x][y + 1] xor used[x][y];
			black[x][y] = up_pref[x][y] xor black[x + 1][y];
		}
	}
	/*for (int y = n - 1; y >= 0; --y)
	{
		for (int x = 0; x < n; ++x)
		{
			cout << black[x][y];
		}
		cout << endl;
	}*/
	

	cout << ans() << endl;
	//return 0;
	while(q--){
		int x1, y1;
		cin >> x1 >> y1;
		x1--;
		y1--;
		black[x1][y1] = !black[x1][y1];

		/*for (int y = n - 1; y >= 0; --y)
		{
			for (int x = 0; x < n; ++x)
			{
				cout << black[x][y];
			}
			cout << endl;
		}*/

		cout << ans() << endl;
	}


}