#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <deque>
#include <queue>
#include <vector>
#include <stack>
#include <string>
#include <fstream>
#include <ctime>
#include <numeric>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vec vector
#define pb push_back

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int SZ = 33;

void solve() {
    int n, m;
    cin >> n >> m;
    set<pair<int, int>> shops;
    set<pair<int, int>> supplies;
    multiset<int> s_sum, s_diff, z_sum, z_diff;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        shops.insert({x, y});
        s_sum.insert(x + y);
        s_diff.insert(x - y);
    }
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        supplies.insert({x, y});
        z_sum.insert(x + y);
        z_diff.insert(x - y);
    }
    int q;
    cin >> q;
    for (; q > 0; --q) {
        int type, x, y;
        cin >> type >> x >> y;
        if (type == 1) {
            if (shops.count({x, y})) {
                shops.erase({x, y});
                s_sum.erase(s_sum.find(x + y));
                s_diff.erase(s_diff.find(x - y));
            } else {
                shops.insert({x, y});
                s_sum.insert(x + y);
                s_diff.insert(x - y);
            }
        } else {
            if (supplies.count({x, y})) {
                supplies.erase({x, y});
                z_sum.erase(z_sum.find(x + y));
                z_diff.erase(z_diff.find(x - y));
            } else {
                supplies.insert({x, y});
                z_sum.insert(x + y);
                z_diff.insert(x - y);
            }
        }
        if ((int)shops.size() == 0 || (int)supplies.size() == 0) {
            cout << "KAPUT\n";
        } else {
            int val1 = *s_sum.rbegin() - *z_sum.begin();
            int val2 = *z_sum.rbegin() - *s_sum.begin();
            int val3 = *s_diff.rbegin() - *z_diff.begin();
            int val4 = *z_diff.rbegin() - *s_diff.begin();
            cout << max({val1, val2, val3, val4}) << endl;
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1; cin >> t;
    for (; t > 0; --t) {
        solve();
    }
}