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

using namespace std;
using namespace __gnu_pbds;

constexpr int M=207;

bool t[M][M];
int matched[M][M][2];
int visited[M][M];
int n, timer;

bool dfs(int x, int y){
	if(visited[x][y] == timer) return 0;
	visited[x][y] = timer;
	
	for(int i=1; i<=n; i++){
		if(t[i][y] == t[x][y]) continue;
		if(!matched[i][y][0]){
			matched[i][y][0] = x;
			matched[i][y][1] = y;
			
			matched[x][y][0] = i;
			matched[x][y][1] = y;			
			return 1;
		}	
	}

	for(int i=1; i<=n; i++){
		if(t[x][i] == t[x][y]) continue;
		if(!matched[x][i][0]){
			matched[x][i][0] = x;
			matched[x][i][1] = y;
			
			matched[x][y][0] = x;
			matched[x][y][1] = i;			
			return 1;
		}	
	}	

	for(int i=1; i<=n; i++){
		if(t[i][y] == t[x][y]) continue;
		if(visited[i][y] != timer && dfs(matched[i][y][0], matched[i][y][1])){
			matched[i][y][0] = x;
			matched[i][y][1] = y;
			
			matched[x][y][0] = i;
			matched[x][y][1] = y;			
			return 1;
		}	
	}

	for(int i=1; i<=n; i++){
		if(t[x][i] == t[x][y]) continue;
		if(visited[x][i] != timer && dfs(matched[x][i][0], matched[x][i][1])){
			matched[x][i][0] = x;
			matched[x][i][1] = y;
			
			matched[x][y][0] = x;
			matched[x][y][1] = i;			
			return 1;
		}	
	}	
	
	return 0;
}

void matching(){
	int res = 0;
	bool ok = 1;
	timer = 0;
	for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) visited[i][j] = matched[i][j][0] = matched[i][j][1] = 0;	
	
	while(ok){
		timer++;
		ok=0;
		for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) if(!matched[i][j][0]) ok|=dfs(i, j);
	}
	
	for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) if(t[i][j] && matched[i][j][0]) res++;
	
	cout << res << '\n';  
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int m, q, a, b, c, d;
	
	cin >> n >> m >> q;
	
	while(m--){
		cin >> a >> b >> c >> d;
		for(int i=a; i<=c; i++) for(int j=b; j<=d; j++) t[i][j]^=1;
	}
	
	matching();
	
	while(q--){
		cin >> a >> b;
		t[a][b]^=1;
		
		matching();
	}
	
	return 0;
}