#include <cstdint>
#include <iostream>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <random>
#include <cfloat>
#include <chrono>
#include <bitset>
#include <complex>
#include <functional>
#include <immintrin.h>
#include <memory>
#include <numbers>

struct PointCloud {
    std::multiset<std::pair<int32_t, std::pair<int32_t, int32_t>>> per_sum;
    std::multiset<std::pair<int32_t, std::pair<int32_t, int32_t>>> per_diff;

    void toggle(int32_t x, int32_t y) {
        if(per_sum.find({x + y, {x, y}}) != per_sum.end()) {
            per_sum.erase(per_sum.find({x + y, {x, y}}));
            per_diff.erase(per_diff.find({x - y, {x, y}}));
        } else {
            per_sum.insert({x + y, {x, y}});
            per_diff.insert({x - y, {x, y}});
        }
    }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int32_t num_tests;
    std::cin >> num_tests;

    for(int32_t t = 0; t < num_tests; t++) {
        int32_t n, m;
        std::cin >> n >> m;

        PointCloud cloud1, cloud2;
        for(int32_t i = 0; i < n; i++) {
            int32_t x, y;
            std::cin >> x >> y;

            cloud1.toggle(x, y);
        }

        for(int32_t i = 0; i < m; i++) {
            int32_t x, y;
            std::cin >> x >> y;

            cloud2.toggle(x, y);
        }

        int32_t num_q;
        std::cin >> num_q;

        for(int32_t q = 0; q < num_q; q++) {
            int32_t type_, x, y;
            std::cin >> type_ >> x >> y;

            if(type_ == 1)
                cloud1.toggle(x, y);
            else
                cloud2.toggle(x, y);

            if(cloud1.per_sum.empty() || cloud2.per_sum.empty()) {
                std::cout << "KAPUT" << "\n";
                continue;
            }

            std::vector<std::pair<int32_t, int32_t>> points1;
            points1.push_back(cloud1.per_sum.begin()->second);
            points1.push_back(cloud1.per_sum.rbegin()->second);
            points1.push_back(cloud1.per_diff.begin()->second);
            points1.push_back(cloud1.per_diff.rbegin()->second);

            std::vector<std::pair<int32_t, int32_t>> points2;
            points2.push_back(cloud2.per_sum.begin()->second);
            points2.push_back(cloud2.per_sum.rbegin()->second);
            points2.push_back(cloud2.per_diff.begin()->second);
            points2.push_back(cloud2.per_diff.rbegin()->second);

            int64_t ans = 0;
            for(auto [x1, y1] : points1)
                for(auto [x2, y2] : points2)
                    ans = std::max(ans, (int64_t)std::abs(x1 - x2) + (int64_t)std::abs(y1 - y2));

            std::cout << ans << "\n";
        }
    }
}
