#include <bits/stdc++.h>
using namespace std;
const int len = 1e6;
const int maxn = 1e6 + 10;
int tree[maxn << 2], lazy[maxn << 2];
int a[maxn], b[maxn];
void push_down(int l, int r, int rt) {
  if (lazy[rt]) {
    int mid = (l + r) / 2;
    tree[rt << 1] += lazy[rt];
    tree[rt << 1 | 1] += lazy[rt];
    lazy[rt << 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    lazy[rt] = 0;
  }
}
void update(int L, int R, int C, int l, int r, int rt) {
  if (L <= l && r <= R) {
    tree[rt] += C;
    lazy[rt] += C;
    return;
  }
  push_down(l, r, rt);
  int mid = (l + r) / 2;
  if (L <= mid) update(L, R, C, l, mid, rt << 1);
  if (R > mid) update(L, R, C, mid + 1, r, rt << 1 | 1);
  tree[rt] = max(tree[rt << 1], tree[rt << 1 | 1]);
}
int query(int l, int r, int rt) {
  if (l == r) return l;
  push_down(l, r, rt);
  int mid = (l + r) / 2;
  if (tree[rt << 1 | 1] > 0)
    return query(mid + 1, r, rt << 1 | 1);
  else
    return query(l, mid, rt << 1);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    update(1, a[i], 1, 1, len, 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    update(1, b[i], -1, 1, len, 1);
  }
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      update(1, a[x], -1, 1, len, 1);
      a[x] = y;
      update(1, a[x], 1, 1, len, 1);
    } else {
      update(1, b[x], 1, 1, len, 1);
      b[x] = y;
      update(1, b[x], -1, 1, len, 1);
    }
    if (tree[1] < 1)
      printf("-1\n");
    else
      printf("%d\n", query(1, len, 1));
  }
  return 0;
}
