#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 6;
const int M = 3e5 + 5;
struct seg {
  int tr[MAXN << 2], lazy[MAXN << 2];
  inline void push_up(int rt) { tr[rt] = max(tr[rt << 1], tr[rt << 1 | 1]); }
  inline void push_down(int rt) {
    if (lazy[rt]) {
      tr[rt << 1] += lazy[rt];
      tr[rt << 1 | 1] += lazy[rt];
      lazy[rt << 1] += lazy[rt];
      lazy[rt << 1 | 1] += lazy[rt];
      lazy[rt] = 0;
    }
  }
  void update(int L, int R, int val, int l, int r, int rt) {
    if (L <= l && r <= R) {
      lazy[rt] += val;
      tr[rt] += val;
      return;
    }
    int mid = (l + r) >> 1;
    push_down(rt);
    if (L <= mid) update(L, R, val, l, mid, rt << 1);
    if (mid < R) update(L, R, val, mid + 1, r, rt << 1 | 1);
    push_up(rt);
  }
  int query(int l, int r, int rt) {
    if (l == r) return l;
    int mid = (l + r) >> 1;
    push_down(rt);
    if (tr[rt << 1 | 1] > 0)
      return query(mid + 1, r, rt << 1 | 1);
    else
      return query(l, mid, rt << 1);
  }
} se;
int a[MAXN], b[MAXN];
int main() {
  int n, m, q;
  const int lim = 1000000;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    se.update(1, a[i], 1, 1, lim, 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    se.update(1, b[i], -1, 1, lim, 1);
  }
  scanf("%d", &q);
  while (q--) {
    int op, id, x;
    scanf("%d%d%d", &op, &id, &x);
    if (op == 1) {
      se.update(1, a[id], -1, 1, lim, 1);
      a[id] = x;
      se.update(1, a[id], 1, 1, lim, 1);
    }
    if (op == 2) {
      se.update(1, b[id], 1, 1, lim, 1);
      b[id] = x;
      se.update(1, b[id], -1, 1, lim, 1);
    }
    if (se.tr[1] <= 0)
      puts("-1");
    else
      printf("%d\n", se.query(1, lim, 1));
  }
  return 0;
}
