#include <bits/stdc++.h>
int max(int x, int y) { return x > y ? x : y; }
int n, m, q, a[1000100], b[1000100];
struct segtree {
  struct node {
    int sum, mx;
    node operator+(node other) const {
      return {sum + other.sum, max(other.mx, mx + other.sum)};
    }
  } t[1000100 * 4];
  void init() { memset(t, 0, sizeof(t)); }
  void update(int id, int l, int r, int x, int value) {
    if (l == r) {
      t[id].sum += value;
      t[id].mx += value;
      return;
    }
    int mid = (l + r) >> 1;
    if (x <= mid)
      update(id * 2, l, mid, x, value);
    else
      update(id * 2 + 1, mid + 1, r, x, value);
    t[id] = t[id * 2] + t[id * 2 + 1];
  }
  int query(int id, int l, int r, struct node cur) {
    if (l == r) return l;
    int mid = (l + r) >> 1;
    struct node nxt = t[id * 2 + 1] + cur;
    if (nxt.mx > 0)
      return query(id * 2 + 1, mid + 1, r, cur);
    else
      return query(id * 2, l, mid, nxt);
  }
} seg;
int main(int argc, char* argv[]) {
  scanf("%d%d", &n, &m);
  seg.init();
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    seg.update(1, 1, 1000000, a[i], 1);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &b[i]);
    seg.update(1, 1, 1000000, b[i], -1);
  }
  scanf("%d", &q);
  int op, x, v;
  while (q--) {
    scanf("%d%d%d", &op, &x, &v);
    switch (op) {
      case 1:
        seg.update(1, 1, 1000000, a[x], -1);
        seg.update(1, 1, 1000000, a[x] = v, +1);
        break;
      case 2:
        seg.update(1, 1, 1000000, b[x], +1);
        seg.update(1, 1, 1000000, b[x] = v, -1);
        break;
      default:
        assert(false);
    }
    if (seg.t[1].mx <= 0) {
      printf("-1\n");
    } else {
      printf("%d\n", seg.query(1, 1, 1000000, segtree::node{0, 0}));
    }
  }
  return 0;
}
