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
#include <bits/stdc++.h>
using namespace std;
const int SIZE=300;
void imax(int &a, int b){
	a=max(a, b);
}
void imin(int &a, int b){
	a=min(a, b);
}
void lmax(long long &a, long long b){
	a=max(a, b);
}
void lmin(long long &a, long long b){
	a=min(a, b);
}
/*
	WARNING: I'm using strange bracket style!
*/
struct Matching{
	static const int INF = 1000000666;
	int n;
	std::vector<std::vector<int> > g;
	std::vector<int> match, col, U, dist;
	Matching(){}
	Matching(int N){
		n = N;
		g = std::vector<std::vector<int> >(n+1);
		match = col = dist = std::vector<int>(n+1);
	}
	void add_edge(int a, int b){
		g[a].push_back(b); g[b].push_back(a);
	}
	void color(int v, int c){
		if((col[v] = c) == 1) U.push_back(v);
		for(auto ch : g[v]) if(!col[ch]) color(ch, (c == 1 ? 2 : 1));
	}
	bool bfs(){
		std::queue<int> que;
		for(auto u : U)
			if(!match[u]) dist[u] = 0, que.push(u);
			else dist[u] = INF;
		dist[0] = INF;
		while(!que.empty()){
			int u = que.front(); que.pop();
			if(dist[u] < dist[0]) for(auto v : g[u]) if(dist[match[v]] == INF)
				dist[match[v]] = dist[u] + 1, que.push(match[v]);
		}
		return dist[0] != INF;
	}
	bool dfs(int u){
		if(!u) return true;
		for(auto v : g[u]) if(dist[match[v]] == dist[u] + 1 && dfs(match[v]))
				return match[v] = u, match[u] = v;
		return dist[u] = INF, false;
	}
	int max_matching(){
		for(int i = 1; i <= n; ++i) if(!col[i]) color(i, 1);
		int ret = 0;
		while(bfs()) for(auto u : U) if(!match[u] && dfs(u)) ret++;
		return ret;
	}
};
int events[SIZE][SIZE];
int arr[SIZE][SIZE];
Matching Knapik;
int n, q, k, A, B, C, D, Q;
void update(int X, int Y, int Z, int T){
	for (int i=X; i<=Z; i++)
		events[i][Y]^=1, events[i][T+1]^=1;
}
int getAns(){
	Knapik=Matching(n*n+n*5);
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++)
			if (arr[i][j])
				for (int g=1; g<=n; g++)
					{
					if (!arr[i][g])
						Knapik.add_edge(i*n+j, i*n+g);
					if (!arr[g][j])
						Knapik.add_edge(i*n+j, g*n+j);
					}
	return Knapik.max_matching();
}
int main()
	{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k>>q;
	while (k--)
		cin>>A>>B>>C>>D, update(A, B, C, D);
	for (int i=1; i<=n; i++)
		{
		k=0;
		for (int j=1; j<=n; j++)
			k^=events[i][j], arr[i][j]=k;
		}
	cout<<getAns()<<"\n";
	while (q--)
		cin>>A>>B, arr[A][B]^=1, cout<<getAns()<<"\n";
	return 0;
	}