#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using u64 = unsigned long long;
using u32 = unsigned int;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, long long>;
using pli = pair<long long, int>;
using pll = pair<long long, long long>;
template <typename T>
using uset = unordered_set<T>;
template <typename T1, typename T2>
using umap = unordered_map<T1, T2>;

template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

#ifndef _DEBUG
#pragma GCC optimize("O3,unroll-loops,fast-math")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif

struct pnt {
    int t, x, y;
};

bool operator<(const pnt &a, const pnt &b) {
    if (a.x != b.x)
        return a.x < b.x;
    if (a.y != b.y)
        return a.y < b.y;
    return a.t < b.t;
}

const ll inf = 3e18;

void smax(ll &a, ll b) {
    a = max(a, b);
}

struct MaxValues {
    ll v00 = -inf, v01 = -inf, v10 = -inf, v11 = -inf;

    MaxValues() {}

    void upd(ll x, ll y) {
        smax(v00, x + y);
        smax(v01, x - y);
        smax(v10, -x + y);
        smax(v11, -x - y);
    }

    ll getMax(const MaxValues &other) {
        ll v = -3e18;
        smax(v, v00 + other.v11);
        smax(v, v01 + other.v10);
        smax(v, v10 + other.v01);
        smax(v, v11 + other.v00);
        return v;
    }

    bool empty() {
        return v00 == -inf;
    }
};

struct segtree {
    vector<vector<pnt>> tree;
    int sz;

    segtree() {}

    segtree(int n) {
        sz = n;
        tree.resize(4 * sz);
    }

    void add(int l, int r, const pnt &p, int v, int tl, int tr) {
        if (l <= tl && tr <= r) {
            tree[v].push_back(p);
            return;
        }
        if (l >= tr || r <= tl)
            return;
        int m = (tl + tr) / 2;
        add(l, r, p, 2 * v + 1, tl, m);
        add(l, r, p, 2 * v + 2, m, tr);
    }

    void add(int l, int r, const pnt &p) {
        add(l, r, p, 0, 0, sz);
    }

    bool bankruptcy = false;

    void dfs(int v, int tl, int tr, MaxValues A, MaxValues B) {
        for (auto &p : tree[v]) {
            if (p.t == 1)
                A.upd(p.x, p.y);
            else
                B.upd(p.x, p.y);
        }
        if (tr - tl == 1) {
            if (A.empty() || B.empty())
                cout << "KAPUT\n";
            else
            cout << A.getMax(B) << '\n';
        } else {
            int m = (tl + tr) / 2;
            dfs(2 * v + 1, tl, m, A, B);
            dfs(2 * v + 2, m, tr, A, B);
        }
    }

    void dfs() {
        dfs(0, 0, sz, MaxValues(), MaxValues());
    }
};

inline void solve() {
    int n, m;
    cin >> n >> m;
    vector<pii> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i].first >> a[i].second;
    vector<pii> b(m);
    for (int i = 0; i < m; i++)
        cin >> b[i].first >> b[i].second;
    map<pnt, int> lst;
    vector<pair<pnt, pii>> evts;
    for (int i = 0; i < n; i++)
        lst[{1, a[i].first, a[i].second}] = 0;
    for (int i = 0; i < m; i++)
        lst[{2, b[i].first, b[i].second}] = 0;
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        pnt p{t, x, y};
        if (lst.count(p)) {
            evts.push_back({p, {lst[p], i}});
            lst.erase(p);
        } else {
            lst[p] = i;
        }
    }
    for (auto &[p, t] : lst)
        evts.push_back({p, {t, q}});
    segtree st(q);
    for (auto [p, seg] : evts)
        st.add(seg.first, seg.second, p);
    st.dfs();
}

signed main() {
#ifdef _DEBUG
    freopen("01.dat", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tt = 1;
    cin >> tt;
    for (int test_id = 1; test_id <= tt; test_id++) {
#ifdef _DEBUG
        cout << "Case #" << test_id << ":\n";
#endif
        solve();
    }
    return 0;
}
