#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int maxn = 3e5 + 5;
int n, m, q;
int a[maxn], b[maxn];
int maxx[N << 2], lazy[N << 2];
void pushup(int rt) { maxx[rt] = max(maxx[rt << 1], maxx[rt << 1 | 1]); }
void pushdown(int rt) {
  if (lazy[rt] == 0) return;
  maxx[rt << 1] += lazy[rt];
  maxx[rt << 1 | 1] += lazy[rt];
  lazy[rt << 1] += lazy[rt];
  lazy[rt << 1 | 1] += lazy[rt];
  lazy[rt] = 0;
}
void update(int rt, int l, int r, int ql, int qr, int val) {
  if (ql <= l && r <= qr) {
    maxx[rt] += val;
    lazy[rt] += val;
  } else {
    int mid = l + r >> 1;
    pushdown(rt);
    if (qr <= mid)
      update(rt << 1, l, mid, ql, qr, val);
    else if (ql > mid)
      update(rt << 1 | 1, mid + 1, r, ql, qr, val);
    else {
      update(rt << 1, l, mid, ql, mid, val);
      update(rt << 1 | 1, mid + 1, r, mid + 1, qr, val);
    }
    pushup(rt);
  }
}
int query(int rt, int l, int r) {
  if (l == r) {
    if (maxx[rt] > 0)
      return l;
    else
      return -1;
  } else {
    int mid = l + r >> 1;
    pushdown(rt);
    if (maxx[rt << 1 | 1] > 0)
      return query(rt << 1 | 1, mid + 1, r);
    else if (maxx[rt << 1] > 0)
      return query(rt << 1, l, mid);
    else
      return -1;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    update(1, 1, N - 1, 1, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    update(1, 1, N - 1, 1, b[i], -1);
  }
  scanf("%d", &q);
  while (q--) {
    int op, pos, x;
    scanf("%d%d%d", &op, &pos, &x);
    if (op == 1) {
      update(1, 1, N - 1, 1, a[pos], -1);
      update(1, 1, N - 1, 1, x, 1);
      a[pos] = x;
    } else {
      update(1, 1, N - 1, 1, b[pos], 1);
      update(1, 1, N - 1, 1, x, -1);
      b[pos] = x;
    }
    int ans = query(1, 1, N - 1);
    printf("%d\n", ans);
  }
  return 0;
}
