#include "testlib.h"
#include <set>
using namespace std;

const int MAX_C = 100000;
const int MAX_N = 100000;
const int MAX_Q = 100000;

int w, h, n;

set<pair<int, int> > was, cells;

int vy[] = {1, 0, -1, 0}, vx[] = {0, 1, 0, -1};

int DFS(int y, int x)
{
    was.insert(make_pair(y, x));
    int ans = 1;
    for (int v = 0; v < 4; v++)
    {
        int ty = y + vy[v];
        int tx = x + vx[v];
        if (ty == 0 || ty == h + 1 || tx == 0 || tx == w + 1)
            continue;
        if (was.find(make_pair(ty, tx)) != was.end())
            continue;
        if (cells.find(make_pair(ty, tx)) == cells.end())
            continue;
        ans += DFS(ty, tx);
    }
    return ans;
}

int main()
{
    registerValidation();
    h = inf.readInt(1, MAX_C);
    inf.readSpace();
    w = inf.readInt(1, MAX_C);
    inf.readEoln();
    n = inf.readInt(1, MAX_N);
    inf.readEoln();
    for (int i = 0; i < n; i++)
    {
        int r = inf.readInt(1, h);
        inf.readSpace();
        int c = inf.readInt(1, w);
        inf.readEoln();
        ensuref(cells.find(make_pair(r, c)) == cells.end(), "cell %d %d appears twice", r, c);
        cells.insert(make_pair(r, c));
    }
    int cnt = DFS(cells.begin()->first, cells.begin()->second);
    ensuref(cnt == n, "initial set of cells isn't connected");
    
    int q = inf.readInt(0, MAX_N);
    inf.readEoln();
    for (int i = 0; i < q; i++)
    {
        int r = inf.readInt(1, h);
        inf.readSpace();
        int c = inf.readInt(1, w);
        inf.readEoln();
        ensuref(cells.find(make_pair(r, c)) == cells.end(), "cell %d %d appears twice", r, c);
        cells.insert(make_pair(r, c));
        bool neigh = false;
        for (int v = 0; v < 4; v++)
        {
            int tr = r + vy[v];
            int tc = c + vx[v];
            neigh |= cells.find(make_pair(tr, tc)) != cells.end();
        }
        ensuref(neigh, "cell %d %d added in query %d doesn't have already added neighbors", r, c, i);
    }
    inf.readEof();
    return 0;
}
