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

int n,m,q,t[2005][2005],x,y,x2,y2,nr[2005][2005],para[4000005],odw[4000005],N = 1;

vector <int> G[4000005],ch;

bool skoj(int v)
{
    odw[v] = N;
    int s = G[v].size();
    for(int i = 0;i < s; i++)
    {
        int u = G[v][i];
        if(!para[u])
        {
            para[u] = v;
            return 1;
        }
        int s2 = G[u].size();
        for(int j = 0;j < s2; j++)
        {
            int w = G[u][j];
            if(odw[w] < N && skoj(w))
            {
                para[u] = v;
                return 1;
            }
        }
    }
    return 0;
}

int szukajSkojarzenia()
{
    int w = 0,s = ch.size();
    N = 1;
    for(int i = 0;i < s; i++, N++)
    {
        if(skoj(ch[i]))
            w++;
    }
    return w;
}



void czysc()
{
    for(int i = 1;i <= n * n; i++)
    {
        para[i] = 0;
        odw[i] = 0;
        G[i].clear();
    }
    ch.clear();
    return;
}

void graf()
{
    for(int i = 1;i <= n; i++)
        for(int j = 1;j <= n; j++)
            if(t[j][i])
            {
                for(int k = 1;k <= n; k++)
                {
                    if(!t[k][i])
                    {
                        G[nr[j][i]].push_back(nr[k][i]);
                        G[nr[k][i]].push_back(nr[j][i]);
                    }
                    if(!t[j][k])
                    {
                        G[nr[j][i]].push_back(nr[j][k]);
                        G[nr[j][k]].push_back(nr[j][i]);
                    }
                }
                ch.push_back(nr[j][i]);
            }
    return;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    cin>>n>>m>>q;
    for(int i = 0;i < m; i++)
    {
        cin>>x>>y>>x2>>y2;
        t[x][y]++;
        t[x2 + 1][y]--;
        t[x][y2 + 1]--;
        t[x2 + 1][y2 + 1]++;
    }
    for(int i = 1;i <= n; i++)
        for(int j = 1;j <= n;j++)
            t[j][i] += t[j - 1][i];
    int p = 1;
    for(int i = 1;i <= n; i++)
        for(int j = 1;j <= n; j++)
        {
            t[i][j] = (t[i][j] + t[i][j - 1] + 2) % 2;
            nr[j][i] = p++;
        }
    graf();
    cout<<szukajSkojarzenia()<<'\n';
    for(int i = 0;i < q; i++)
    {
        cin>>x>>y;
        czysc();
        t[x][y]++;
        t[x][y] %= 2;
        graf();
        cout<<szukajSkojarzenia()<<'\n';
    }
    return 0;
}