#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int M = 1e6;
int sum[N * 10], tree[N * 10], n, m, a[N], b[N], q;
void update(int x, int l, int r, int p, int val) {
  sum[x] += val;
  if (l == r) {
    tree[x] = max(sum[x], 0);
    return;
  }
  int mid = (l + r) >> 1;
  if (p <= mid)
    update(x << 1, l, mid, p, val);
  else
    update(x << 1 | 1, mid + 1, r, p, val);
  tree[x] = max(tree[x << 1 | 1], tree[x << 1] + sum[x << 1 | 1]);
  return;
}
int query(int x, int l, int r, int p) {
  if (p <= l) return tree[x];
  int mid = (l + r) >> 1;
  if (p <= mid) {
    int ls = query(x << 1, l, mid, p), rs = tree[x << 1 | 1];
    return max(ls + sum[x << 1 | 1], rs);
  } else
    return query(x << 1 | 1, mid + 1, r, p);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    update(1, 1, M, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    update(1, 1, M, b[i], -1);
  }
  scanf("%d", &q);
  while (q--) {
    int opt, p, x;
    scanf("%d %d %d", &opt, &p, &x);
    if (opt == 1) {
      update(1, 1, M, a[p], -1);
      a[p] = x;
      update(1, 1, M, a[p], 1);
    } else {
      update(1, 1, M, b[p], 1);
      b[p] = x;
      update(1, 1, M, b[p], -1);
    }
    int l = 0, r = M, mid;
    while (l < r) {
      mid = (l + r) >> 1;
      int tmp = query(1, 1, M, mid + 1);
      if (query(1, 1, M, mid + 1) > 0)
        l = mid + 1;
      else
        r = mid;
    }
    printf("%d\n", l ? l : -1);
  }
  return 0;
}
