#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e6 + 5;
struct node {
  int val;
  int addMark;
} tree[maxn];
void build(int rt, int is, int ie) {
  for (int i = is; i <= ie; i++) {
    tree[i].val = 0;
    tree[i].addMark = 0;
  }
}
void pushDown(int rt) {
  if (tree[rt].addMark != 0) {
    tree[rt << 1].addMark += tree[rt].addMark;
    tree[rt << 1 | 1].addMark += tree[rt].addMark;
    tree[rt << 1].val += tree[rt].addMark;
    tree[rt << 1 | 1].val += tree[rt].addMark;
    tree[rt].addMark = 0;
  }
}
void update(int rt, int ns, int ne, int us, int ue, int val) {
  if (us > ne || ue < ns) {
    return;
  }
  if (us <= ns && ue >= ne) {
    tree[rt].addMark += val;
    tree[rt].val += val;
    return;
  }
  pushDown(rt);
  int mid = (ns + ne) / 2;
  update(rt << 1, ns, mid, us, ue, val);
  update(rt << 1 | 1, mid + 1, ne, us, ue, val);
  tree[rt].val = max(tree[rt << 1].val, tree[rt << 1 | 1].val);
}
int query(int rt, int ns, int ne, int qs, int qe) {
  if (qs > ne || qe < ns) {
    return -1;
  }
  if (qs <= ns && qe >= ne) {
    return tree[rt].val;
  }
  pushDown(rt);
  int mid = (ns + ne) / 2;
  return max(query(rt << 1, ns, mid, qs, qe),
             query(rt << 1 | 1, mid + 1, ne, qs, qe));
}
int a[300005], b[300005];
const int inf = 1000000;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  build(1, 1, inf);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    update(1, 1, inf, 1, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    update(1, 1, inf, 1, b[i], -1);
  }
  int q;
  scanf("%d", &q);
  int f, x, y;
  for (int i = 0; i < q; i++) {
    scanf("%d %d %d", &f, &x, &y);
    if (f == 1) {
      update(1, 1, inf, 1, a[x], -1);
      a[x] = y;
      update(1, 1, inf, 1, a[x], 1);
    } else {
      update(1, 1, inf, 1, b[x], 1);
      b[x] = y;
      update(1, 1, inf, 1, b[x], -1);
    }
    int l = 1, r = inf, m;
    while (r - l > 1) {
      m = (l + r) / 2;
      if (query(1, 1, inf, m, inf) > 0) {
        l = m;
      } else {
        r = m;
      }
    }
    if (query(1, 1, inf, r, inf) > 0)
      printf("%d\n", r);
    else if (query(1, 1, inf, l, inf) > 0)
      printf("%d\n", l);
    else
      printf("-1\n");
  }
}
