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
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include<cmath>
using namespace std;

int zmiana(int** tab, int x1, int y1, int x2, int y2,int czarne)
{ 
    for (int i = x1; i <= x2; i++)
    {
        int dod = 0, od = 0;
        for (int z = y1; z <= y2; z++)
        {
          
            if (tab[i][z] == 1)
            {
                tab[i][z] = 0;
                czarne--;
                od++;

            }
            else if (tab[i][z] == 0)
            {
                tab[i][z] = 1;
                czarne++;
                dod++;

            }
            
        }
        tab[i][0] += (dod - od);

    }
    return czarne;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int m, n, t;
    cin >> m >> n >> t;
    int** tab = new int* [m+2];
    for (int i = 0; i < m + 2; i++)
        tab[i] = new int[m + 2]();
    int biale = m * m, czarne=0;
    for (int i = 0; i < n; i++)
    {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        czarne=zmiana(tab, x1, y1, x2, y2,czarne);
    
    }
    biale -= czarne;
    for (int i = 1; i <= m; i++)
    {
        int dod = 0, od = 0;
        for (int z = 1; z <= m; z++)
        {

            if (tab[z][i] == 1)
                dod++;


        }
        tab[0][i] += dod;

    }
    int odejmij=0;
    for (int i = 1; i <= m; i++)
    {
        if (tab[i][0] ==m) 
        for (int z = 0; z <= m; z++)
            if ( tab[0][z] == m)
                odejmij++;
    }
    
    cout << min(biale, czarne)- odejmij << endl;
    
    for (int i = 0; i < t; i++)
    {
        int x, y;
        cin >> x >> y;
        bool flag = 0;
        if (tab[x][0] == m && tab[0][y] == m)
            flag = 1;
        if (tab[x][y] == 1)
        {
            tab[x][y] == 0;
            czarne--;
            biale++;
            tab[x][0] --;
            tab[0][y]--;

        }
        else if (tab[x][y] == 0)
        {
            tab[x][y] == 1;
            czarne++;
            biale--;
            tab[x][0] ++;
            tab[0][y] ++;
        }
        if (flag == 0)
        {
            if (tab[x][0] == m && tab[0][y] == m)
                odejmij++;
        }
        else if (flag == 1)
        {
            if (tab[x][0] < m && tab[0][y] < m)
                odejmij--;
        }
        cout << min(biale, czarne) - odejmij << "\n";
    }
    return 0;
}