#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 pq_pro_max {
    priority_queue<ll> q, del;

    void insert(ll x) {
        q.push(x);
    }

    void pop() {
        q.pop();
    }

    void erase(ll x) {
        del.push(x);
    }

    void flush() {
        while (!del.empty() && q.top() == del.top()) {
            q.pop();
            del.pop();
        }
    }

    bool empty() {
        flush();
        return q.empty();
    }

    ll top() {
        flush();
        return q.top();
    }
};

struct PointSet {
    pq_pro_max st00, st01, st10, st11;
    set<pii> pts;

    PointSet() {}

    void insert(ll x, ll y) {
        pts.insert({x, y});
        st00.insert(x + y);
        st01.insert(x - y);
        st10.insert(-x + y);
        st11.insert(-x - y);
    }

    void erase(ll x, ll y) {
        pts.erase({x, y});
        st00.erase(x + y);
        st01.erase(x - y);
        st10.erase(-x + y);
        st11.erase(-x - y);
    }

    void change(int x, int y) {
        if (pts.count({x, y}))
            erase(x, y);
        else
            insert(x, y);
    }

    bool empty() {
        return pts.empty();
    }

    ll get00() {
        return st00.top();
    }

    ll get01() {
        return st01.top();
    }

    ll get10() {
        return st10.top();
    }

    ll get11() {
        return st11.top();
    }
};

inline void solve() {
    int n, m;
    cin >> n >> m;
    PointSet A, B;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        A.insert(x, y);
    }
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        B.insert(x, y);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1)
            A.change(x, y);
        else
            B.change(x, y);
        if (A.empty() || B.empty()) {
            cout << "KAPUT\n";
            continue;
        }
        ll ans = 0;
        ans = max(ans, A.get00() + B.get11());
        ans = max(ans, A.get01() + B.get10());
        ans = max(ans, A.get10() + B.get01());
        ans = max(ans, A.get11() + B.get00());
        cout << ans << '\n';
    }
}

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;
}
