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
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}
// head

const int N=1e3+5;

#define INF 0x3f3f3f3f

template<class T> inline void read(T &x) {
    x=0; int c=getchar(),f=1;
    for (;!isdigit(c);c=getchar()) if (c==45) f=-1;
    for (;isdigit(c);c=getchar()) (x*=10)+=f*(c-'0');
}
int n,m,q;
bool a[N][N];
set<int> e[N*N];

class Hopcroft {
public:
	static const int MAXN=1e3+5;
  int cnt,pos[MAXN*MAXN],neg[MAXN*MAXN];
  int gao(int n) {
    fill(pos,pos+n,-1);
    fill(neg,neg+n,-1);
    for (int x=cnt=0,y;x<n;x++) for (auto it:e[x]) {
      if (~neg[y=it]) continue;
      pos[neg[y]=x]=y;
      cnt++; break;
    }
    while (true) {
      int push=0,pop=0,ok=0;
      fill(lx,lx+n,-1);
      fill(ly,ly+n,-1);
      for (int x=0;x<n;x++) if (pos[x]<0) lx[q[push++]=x]=0;
      while (push!=pop) {
        int x=q[pop++],y;
        for (auto it:e[x]) {
          if (~ly[y=it]) continue;
          ly[y]=1+lx[x];
          if (~neg[y]&&~lx[neg[y]]) continue;
          if (~neg[y]) lx[q[push++]=neg[y]]=1+ly[y];
          else ok=1;
        }
      }
      if (!ok) return cnt;
      for (int x=0;x<n;x++) if (pos[x]<0&&aug(x)) cnt++;
    }
  }
private:
  int lx[MAXN*MAXN],ly[MAXN*MAXN],q[MAXN*MAXN];
  bool aug(int x) {
    int c=lx[x]+1,y=lx[x]=-1;
   	for (auto it:e[x]) if (ly[y=it]==c) {
      ly[y]=-1;
      if (~neg[y]&&!aug(neg[y])) continue;
      pos[neg[y]=x]=y;
      return true;
    }
    return false;
  }
}H;

int main() {
	read(n); read(m); read(q);
	rep(i,0,m) {
		int i1,j1,i2,j2;
		read(i1); read(j1); read(i2); read(j2);
		i1--; j1--; i2--; j2--;
		rep(j,i1,i2+1) rep(k,j1,j2+1) a[j][k]^=1;
	}
	rep(i,0,n) rep(j,0,n) if (a[i][j]) {
		int pos=i*n+j;
		rep(k,0,n) if (!a[k][j]) e[pos].insert(k*n+j);
		rep(k,0,n) if (!a[i][k]) e[pos].insert(i*n+k);
	}
	printf("%d\n",H.gao(n*n));
	rep(z,0,q) {
		int x,y;
		read(x); read(y);
		x--; y--;
		a[x][y]^=1;
		int pos=x*n+y;
		if (!a[x][y]) {
			rep(i,0,n) if (i!=x&&a[i][y]) e[i*n+y].insert(pos);
			rep(i,0,n) if (i!=y&&a[x][i]) e[x*n+i].insert(pos);
			e[pos].clear();
		}
		else {
			rep(i,0,n) if (i!=x&&a[i][y]) e[i*n+y].erase(pos);
			rep(i,0,n) if (i!=y&&a[x][i]) e[x*n+i].erase(pos);
			rep(i,0,n) if (!a[i][y]) e[pos].insert(i*n+y);
			rep(i,0,n) if (!a[x][i]) e[pos].insert(x*n+i);
		}
		printf("%d\n",H.gao(n*n));
	}
}