#include <bits/stdc++.h>
#include "testlib.h"

using namespace std;

using ll = long long;
using pii = pair<int, int>;

const int maxN = 500'000;
const int maxA = 1'000'000'000;

int main(int argc, char** argv) {
    registerValidation(argc, argv);
    int tests = inf.readInt(1, 10'000, "~t");
    inf.readEoln();
    ll sumn = 0, summ = 0, sumq = 0;
    for (int test = 1; test <= tests; test++) {
        setTestCase(test);
        int n, m;
        n = inf.readInt(1, maxN, "~n");
        inf.readSpace();
        m = inf.readInt(1, maxN, "~m");
        inf.readEoln();
        set<pii> A, B;
        for (int i = 0; i < n; i++) {
            int x, y;
            x = inf.readInt(-maxA, maxA, "~x_i");
            inf.readSpace();
            y = inf.readInt(-maxA, maxA, "~y_i");
            inf.readEoln();
            ensuref(!A.count({x, y}), "shops aren't unique");
            A.insert({x, y});
        }
        for (int i = 0; i < m; i++) {
            int x, y;
            x = inf.readInt(-maxA, maxA, "~x_i");
            inf.readSpace();
            y = inf.readInt(-maxA, maxA, "~y_i");
            inf.readEoln();
            ensuref(!B.count({x, y}), "clients aren't unique");
            B.insert({x, y});
        }
        int q = inf.readInt(1, maxN, "~q");
        inf.readEoln();
        while (q--) {
            int t, x, y;
            t = inf.readInt(1, 2, "~t");
            inf.readSpace();
            x = inf.readInt(-maxA, maxA, "~x");
            inf.readSpace();
            y = inf.readInt(-maxA, maxA, "~y");
            inf.readEoln();
        }
        sumn += n;
        summ += m;
        sumq += q;
        ensuref(sumn <= maxN, "sum of n is too big");
        ensuref(summ <= maxN, "sum of m is too big");
        ensuref(sumq <= maxN, "sum of q is too big");
    }
    inf.readEof();
    return 0;
}