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
from sys import stdin, stdout


def brute(klocki):
    count_start = len(klocki)
    to_remove = []
    klocki_left = klocki.copy()
    for k in klocki:
        up = (k[0] - 1, k[1])
        down = (k[0] + 1, k[1])
        left = (k[0], k[1]-1)
        right = (k[0], k[1]+1)
        if (up not in klocki_left) and (down not in klocki_left):
            if left in klocki_left:
                to_remove.append(left)
            if right in klocki_left:
                to_remove.append(right)
            if k in klocki_left:
                klocki_left.remove(k)
        if (left not in klocki_left) and (right not in klocki_left):
            if up in klocki_left:
                to_remove.append(up)
            if down in klocki_left:
                to_remove.append(down)
            if k in klocki_left:
                klocki_left.remove(k)
    i = 0
    while i < len(to_remove):
        k = to_remove[i]
        up = (k[0] - 1, k[1])
        down = (k[0] + 1, k[1])
        left = (k[0], k[1]-1)
        right = (k[0], k[1]+1)
        if (up not in klocki_left) and (down not in klocki_left):
            if left in klocki_left:
                to_remove.append(left)
            if right in klocki_left:
                to_remove.append(right)
            if k in klocki_left:
                klocki_left.remove(k)
        if (left not in klocki_left) and (right not in klocki_left):
            if up in klocki_left:
                to_remove.append(up)
            if down in klocki_left:
                to_remove.append(down)
            if k in klocki_left:
                klocki_left.remove(k)
        i += 1
    return count_start - len(klocki_left)


n, m, k, q = [int(x) for x in stdin.readline().split()]
klocki_start = set()
for _ in range(k):
    x, y = [int(x) for x in stdin.readline().split()]
    klocki_start.add((x, y))
klocki_update = []
for _ in range(q):
    x, y = [int(x) for x in stdin.readline().split()]
    klocki_update.append((x, y))


stdout.write(str(brute(klocki_start)) + "\n")
for i in range(q):
    new_k = klocki_update[i]
    if new_k in klocki_start:
        klocki_start.remove(new_k)
    else:
        klocki_start.add(klocki_update[i])
    stdout.write(str(brute(klocki_start)) + "\n")