#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const long long MAX = 5e18;
struct node {
  int l, r;
};
int n, m, a[N], b[N], x, y, t, q;
struct segTree {
  node s[1 << 21];
  void build() { memset(s, 0, sizeof s); }
  void handle(int i) {
    int m = min(s[i].l, s[i].r);
    s[i].l -= m;
    s[i].r -= m;
  }
  node mrg(node x, node y) {
    int z = min(x.l, y.r);
    return {x.l + y.l - z, x.r + y.r - z};
  }
  void add(int x, bool b, int v, int from = 0, int to = N - 1, int i = 0) {
    if (from == to) {
      if (b)
        s[i].r += v;
      else
        s[i].l += v;
      handle(i);
      return;
    }
    int mid = (from + to) >> 1, l = 2 * i + 1, r = l + 1;
    if (x <= mid)
      add(x, b, v, from, mid, l);
    else
      add(x, b, v, mid + 1, to, r);
    s[i] = mrg(s[l], s[r]);
  }
  node get(int x, int from = 0, int to = N - 1, int i = 0) {
    if (to < x) return {0, 0};
    if (from >= x) return s[i];
    int mid = (from + to) >> 1, l = 2 * i + 1, r = l + 1;
    if (x > mid) return get(x, mid + 1, to, r);
    return mrg(get(x, from, mid, l), get(x, mid + 1, to, r));
  }
  int bs() {
    int st = 0, en = N - 1, mid;
    while (st < en) {
      mid = (st + en + 1) >> 1;
      if (get(mid).l)
        st = mid;
      else
        en = mid - 1;
    }
    if (get(st).l) return st;
    return -1;
  }
} tree;
int main() {
  scanf("%d%d", &n, &m);
  tree.build();
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    tree.add(a[i], 0, 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", b + i);
    tree.add(b[i], 1, 1);
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      tree.add(a[x], 0, -1);
      a[x] = y;
      tree.add(a[x], 0, 1);
    } else {
      tree.add(b[x], 1, -1);
      b[x] = y;
      tree.add(b[x], 1, 1);
    }
    printf("%d\n", tree.bs());
  }
  return 0;
}
