#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
const int inf = 1e6;
int n, m;
int a[maxn + 5], b[maxn + 5];
int tag[maxn << 2], mx[maxn << 2];
void seta(int p, int d) {
  tag[p] += d;
  mx[p] += d;
}
void push(int p) {
  seta(p + p, tag[p]);
  seta(p + p + 1, tag[p]);
  tag[p] = 0;
}
void modify(int p, int l, int r, int ql, int qr, int d) {
  if (l == ql && r == qr) {
    seta(p, d);
    return;
  }
  push(p);
  int mid = (l + r) >> 1;
  if (qr <= mid)
    modify(p + p, l, mid, ql, qr, d);
  else if (mid < ql)
    modify(p + p + 1, mid + 1, r, ql, qr, d);
  else
    modify(p + p, l, mid, ql, mid, d),
        modify(p + p + 1, mid + 1, r, mid + 1, qr, d);
  mx[p] = max(mx[p + p], mx[p + p + 1]);
}
int query(int p, int l, int r) {
  if (l == r) return l;
  push(p);
  int mid = (l + r) >> 1;
  if (mx[p + p + 1] > 0)
    return query(p + p + 1, mid + 1, r);
  else
    return query(p + p, l, mid);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    modify(1, 1, inf, 1, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    modify(1, 1, inf, 1, b[i], -1);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int op, i, x;
    scanf("%d %d %d", &op, &i, &x);
    if (op == 1) {
      modify(1, 1, inf, 1, a[i], -1);
      a[i] = x;
      modify(1, 1, inf, 1, a[i], 1);
    } else {
      modify(1, 1, inf, 1, b[i], 1);
      b[i] = x;
      modify(1, 1, inf, 1, b[i], -1);
    }
    if (mx[1] <= 0)
      printf("%d\n", -1);
    else
      printf("%d\n", query(1, 1, inf));
  }
  return 0;
}
