#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, mx, flag;
} tree[1000005 * 4];
int n, m, a[300005], q, b[300005];
void build(int i, int l, int r) {
  tree[i].l = l, tree[i].r = r;
  if (l == r) return;
  int mid = (l + r) / 2;
  build(i * 2, l, mid);
  build(i * 2 + 1, mid + 1, r);
}
void push_down(int i) {
  if (!tree[i].flag) return;
  tree[i * 2].mx += tree[i].flag;
  tree[i * 2 + 1].mx += tree[i].flag;
  tree[i * 2 + 1].flag += tree[i].flag;
  tree[i * 2].flag += tree[i].flag;
  tree[i].flag = 0;
}
void update(int i, int l, int r, int x) {
  if (l <= tree[i].r && tree[i].r <= r) {
    tree[i].mx += x;
    tree[i].flag += x;
    return;
  }
  if (tree[i].r < l || tree[i].l > r) return;
  push_down(i);
  update(i * 2, l, r, x);
  update(i * 2 + 1, l, r, x);
  tree[i].mx = max(tree[i * 2].mx, tree[i * 2 + 1].mx);
}
int query(int i) {
  if (tree[i].mx <= 0) return -1;
  if (tree[i].l == tree[i].r) return tree[i].l;
  push_down(i);
  if (tree[i * 2 + 1].mx > 0)
    return query(i * 2 + 1);
  else
    return query(i * 2);
}
int main() {
  scanf("%d%d", &n, &m);
  build(1, 1, 1000000);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    update(1, 1, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    update(1, 1, b[i], -1);
  }
  scanf("%d", &q);
  while (q--) {
    int flag, ind, x;
    scanf("%d%d%d", &flag, &ind, &x);
    if (flag == 1) {
      update(1, 1, a[ind], -1);
      update(1, 1, x, 1);
      a[ind] = x;
    } else {
      update(1, 1, b[ind], 1);
      update(1, 1, x, -1);
      b[ind] = x;
    }
    printf("%d\n", query(1));
  }
}
