#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("vpt")
#pragma GCC optimize("rename-registers")
#pragma GCC optimize("move-loop-invariants")
#pragma GCC optimize("unswitch-loops")
#pragma GCC optimize("branch-target-load-optimize2")
#pragma GCC optimize("btr-bb-exclusive")
using namespace std;
const int nax = 300000, inf = 1000000007;
mt19937 rnd(48829893);
struct Node {
  int val, p, size, add, f;
  Node *left, *right;
  Node(int x)
      : val(x),
        p(rnd()),
        size(1),
        add(0),
        f(x),
        left(nullptr),
        right(nullptr) {}
};
int size(Node* root) { return root ? root->size : 0; }
void push(Node* root) {
  if (root && root->add) {
    root->val += root->add;
    root->f += root->add;
    if (root->left) root->left->add += root->add;
    if (root->right) root->right->add += root->add;
    root->add = 0;
  }
}
int f(Node* root) {
  push(root);
  return root ? root->f : inf;
}
void update(Node* root) {
  if (root) {
    root->size = size(root->left) + size(root->right) + 1;
    root->f = min({root->val, f(root->left), f(root->right)});
  }
}
Node* merge(Node* left, Node* right) {
  push(left), push(right);
  if (!left || !right) return left ? left : right;
  if (left->p > right->p) {
    left->right = merge(left->right, right);
    update(left);
    return left;
  }
  right->left = merge(left, right->left);
  update(right);
  return right;
}
void split(Node* root, int key, int pr, Node*& left, Node*& right) {
  if (!root) return void(left = right = nullptr);
  push(root);
  int x = size(root->left) + pr + 1;
  if (x < key) {
    left = root;
    split(root->right, key, x, root->right, right);
  } else {
    right = root;
    split(root->left, key, pr, left, root->left);
  }
  update(root);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m, q;
  Node *root = nullptr, *left, *right;
  cin >> n >> m;
  vector<int> a(n), b(m);
  for (int i = 1; i <= nax; ++i) root = merge(root, new Node(0));
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    split(root, a[i] + 1, 0, left, right);
    --left->add;
    root = merge(left, right);
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
    split(root, b[i] + 1, 0, left, right);
    ++left->add;
    root = merge(left, right);
  }
  cin >> q;
  while (q--) {
    int cmd, i, x;
    cin >> cmd >> i >> x;
    if (cmd & 1) {
      split(root, a[i - 1] + 1, 0, left, right);
      ++left->add;
      root = merge(left, right);
      split(root, x + 1, 0, left, right);
      --left->add;
      a[i - 1] = x;
    } else {
      split(root, b[i - 1] + 1, 0, left, right);
      --left->add;
      root = merge(left, right);
      split(root, x + 1, 0, left, right);
      ++left->add;
      b[i - 1] = x;
    }
    root = merge(left, right);
    if (f(root) < 0) {
      int l = 1, r = nax;
      while (r - l > 1) {
        int mid = (l + r) / 2;
        split(root, mid, 0, left, right);
        if (f(right) < 0)
          l = mid;
        else
          r = mid;
        root = merge(left, right);
      }
      split(root, r, 0, left, right);
      if (f(right) < 0)
        cout << r << '\n';
      else
        cout << l << '\n';
      root = merge(left, right);
    } else
      cout << "-1\n";
  }
  return 0;
}
