#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int MAXN = 1e6 + 10, N = 1e6;
int mx[MAXN * 4], tag[MAXN * 4], a[MAXN], b[MAXN];
void pushdown(int o, int ls, int rs) {
  if (tag[o] != 0) {
    tag[ls] += tag[o];
    tag[rs] += tag[o];
    mx[ls] += tag[o];
    mx[rs] += tag[o];
    tag[o] = 0;
  }
}
void up(int o, int l, int r, int ql, int qr, int v) {
  if (l >= ql && r <= qr) {
    mx[o] += v;
    tag[o] += v;
    return;
  }
  int m = (l + r) / 2, ls = o * 2, rs = o * 2 + 1;
  pushdown(o, ls, rs);
  if (ql <= m) up(ls, l, m, ql, qr, v);
  if (qr > m) up(rs, m + 1, r, ql, qr, v);
  mx[o] = max(mx[ls], mx[rs]);
}
int qu(int o, int l, int r) {
  if (l == r) return l;
  int m = (l + r) / 2, ls = o * 2, rs = o * 2 + 1;
  pushdown(o, ls, rs);
  if (mx[rs] > 0) return qu(rs, m + 1, r);
  return qu(ls, l, m);
}
int main() {
  int n, m, q, opt, x, y;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    up(1, 1, N, 1, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    up(1, 1, N, 1, b[i], -1);
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 1) {
      up(1, 1, N, 1, a[x], -1);
      a[x] = y;
      up(1, 1, N, 1, a[x], 1);
    } else {
      up(1, 1, N, 1, b[x], 1);
      b[x] = y;
      up(1, 1, N, 1, b[x], -1);
    }
    if (mx[1] <= 0)
      puts("-1");
    else
      printf("%d\n", qu(1, 1, N));
  }
}
