#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int mx[N << 2], lz[N << 2], sum[N << 2], a[N], b[N];
void pushup(int rt) { mx[rt] = max(mx[(rt << 1)], mx[(rt << 1 | 1)]); }
void pushdown(int rt) {
  if (lz[rt]) {
    lz[(rt << 1)] += lz[rt];
    lz[(rt << 1 | 1)] += lz[rt];
    mx[(rt << 1)] += lz[rt];
    mx[(rt << 1 | 1)] += lz[rt];
    lz[rt] = 0;
  }
}
void up(int L, int R, int val, int l = 1, int r = 1000000, int rt = 1) {
  if (L <= l && R >= r) {
    mx[rt] += val;
    lz[rt] += val;
  } else {
    pushdown(rt);
    if (((l + r) >> 1) >= L) up(L, R, val, l, ((l + r) >> 1), (rt << 1));
    if (((l + r) >> 1) + 1 <= R)
      up(L, R, val, ((l + r) >> 1) + 1, r, (rt << 1 | 1));
    pushup(rt);
  }
}
int f(int l = 1, int r = 1000000, int rt = 1) {
  if (l == r) return l;
  pushdown(rt);
  if (mx[(rt << 1 | 1)] > 0)
    return f(((l + r) >> 1) + 1, r, (rt << 1 | 1));
  else
    return f(l, ((l + r) >> 1), (rt << 1));
}
int main() {
  int n, m, q;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), up(1, a[i], 1);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]), up(1, b[i], -1);
  scanf("%d", &q);
  while (q--) {
    int x, i, j;
    scanf("%d %d %d", &x, &i, &j);
    if (x == 1)
      up(1, a[i], -1), up(1, j, 1), a[i] = j;
    else
      up(1, b[i], 1), up(1, j, -1), b[i] = j;
    printf("%d\n", mx[1] > 0 ? f() : -1);
  }
}
