#include <bits/stdc++.h>
using namespace std;
int n, m, q, a[1000010], b[1000010];
struct SEG {
  struct node {
    int sum, Max;
    node() { sum = Max = 0; }
    node(int sum, int Max) : sum(sum), Max(Max) {}
    node operator+(const node &other) const {
      node res = node();
      res.sum = sum + other.sum;
      res.Max = max(other.Max, Max + other.sum);
      return res;
    }
  } t[1000010 << 2];
  void init() { memset(t, 0, sizeof t); }
  void update(int id, int l, int r, int x, int v) {
    if (l == r) {
      t[id].sum += v;
      t[id].Max += v;
      return;
    }
    int mid = (l + r) >> 1;
    if (x <= mid)
      update(id << 1, l, mid, x, v);
    else
      update(id << 1 | 1, mid + 1, r, x, v);
    t[id] = t[id << 1] + t[id << 1 | 1];
  }
  int query(int id, int l, int r, node tmp) {
    if (l == r) {
      return l;
    }
    int mid = (l + r) >> 1;
    node tmp2 = t[id << 1 | 1] + tmp;
    if (tmp2.Max > 0) {
      return query(id << 1 | 1, mid + 1, r, tmp);
    } else {
      return query(id << 1, l, mid, tmp2);
    }
  }
} seg;
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    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(0);
      }
      if (seg.t[1].Max <= 0) {
        puts("-1");
      } else {
        printf("%d\n", seg.query(1, 1, 1000000, SEG::node(0, 0)));
      }
    }
  }
  return 0;
}
