#include <bits/stdc++.h>
using namespace std;
const int Maxn = 300005;
const int Maxk = 1000005;
int mx[Maxk << 2], lazy[Maxk << 2];
inline void pushup(int p) { mx[p] = max(mx[(p << 1)], mx[(p << 1 | 1)]); }
inline void pushdown(int p) {
  if (!lazy[p]) return;
  mx[(p << 1)] += lazy[p];
  lazy[(p << 1)] += lazy[p];
  mx[(p << 1 | 1)] += lazy[p];
  lazy[(p << 1 | 1)] += lazy[p];
  lazy[p] = 0;
}
void modify(int L, int R, int val, int p, int l, int r) {
  if (L <= l && r <= R) {
    mx[p] += val, lazy[p] += val;
    return;
  }
  if (L > r || l > R) return;
  pushdown(p);
  modify(L, R, val, (p << 1), l, (l + r >> 1));
  modify(L, R, val, (p << 1 | 1), (l + r >> 1) + 1, r);
  pushup(p);
}
int query(int p, int l, int r) {
  if (l == r) {
    if (mx[p] > 0) return l;
    return -1;
  }
  pushdown(p);
  if (mx[(p << 1 | 1)] > 0) return query((p << 1 | 1), (l + r >> 1) + 1, r);
  return query((p << 1), l, (l + r >> 1));
}
int n, m, q;
int a[Maxn], b[Maxn];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    modify(1, a[i], 1, 1, 1, 1000000);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", b + i);
    modify(1, b[i], -1, 1, 1, 1000000);
  }
  scanf("%d", &q);
  while (q--) {
    int op, x, val;
    scanf("%d %d %d", &op, &x, &val);
    if (op == 1) {
      if (a[x] < val)
        modify(a[x] + 1, val, 1, 1, 1, 1000000);
      else
        modify(val + 1, a[x], -1, 1, 1, 1000000);
      a[x] = val;
    } else {
      if (b[x] < val)
        modify(b[x] + 1, val, -1, 1, 1, 1000000);
      else
        modify(val + 1, b[x], 1, 1, 1, 1000000);
      b[x] = val;
    }
    printf("%d\n", query(1, 1, 1000000));
  }
  return 0;
}
