#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int n, m, q, a[maxn], b[maxn], total = 1e6;
int st[maxn << 2], lazy[maxn << 2];
void pushDown(int rt) {
  if (lazy[rt]) {
    st[(rt << 1)] += lazy[rt];
    st[(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 L, int R, int val) {
  if (l <= L && R <= r) {
    st[rt] += val;
    lazy[rt] += val;
    return;
  }
  pushDown(rt);
  int mid = (L + R) >> 1;
  if (l <= mid) update((rt << 1), l, r, L, mid, val);
  if (r > mid) update((rt << 1 | 1), l, r, mid + 1, R, val);
  st[rt] = max(st[(rt << 1)], st[(rt << 1 | 1)]);
}
int query(int rt, int L, int R) {
  if (st[rt] < 1) return -1;
  if (L == R) return L;
  pushDown(rt);
  int mid = (L + R) >> 1;
  if (st[(rt << 1 | 1)] >= 1)
    return query((rt << 1 | 1), mid + 1, R);
  else
    return query((rt << 1), L, mid);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= m; ++i) scanf("%d", &b[i]);
  for (int i = 1; i <= n; ++i) update(1, 1, a[i], 1, total, 1);
  for (int i = 1; i <= m; ++i) update(1, 1, b[i], 1, total, -1);
  scanf("%d", &q);
  while (q--) {
    int op, i, x;
    scanf("%d%d%d", &op, &i, &x);
    if (op == 1) {
      update(1, 1, a[i], 1, total, -1);
      a[i] = x;
      update(1, 1, a[i], 1, total, 1);
    } else {
      update(1, 1, b[i], 1, total, 1);
      b[i] = x;
      update(1, 1, b[i], 1, total, -1);
    }
    int ans = query(1, 1, total);
    printf("%d\n", ans);
  }
  return 0;
}
