#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int mx[N << 2], lz[N << 2], sum[N << 2], a[N], b[N];
void pushup(int rt) { mx[rt] = max(mx[(rt << 1)], mx[(rt << 1 | 1)]); }
void pushdown(int rt) {
  if (lz[rt]) {
    mx[(rt << 1)] += lz[rt];
    mx[(rt << 1 | 1)] += lz[rt];
    lz[(rt << 1)] += lz[rt];
    lz[(rt << 1 | 1)] += lz[rt];
    lz[rt] = 0;
  }
}
void up(int L, int R, int val, int l = 1, int r = 1e6, int rt = 1) {
  if (L <= l && R >= r) {
    mx[rt] += val;
    lz[rt] += val;
  } else {
    pushdown(rt);
    if (((l + r) >> 1) >= L) up(L, R, val, l, ((l + r) >> 1), (rt << 1));
    if (((l + r) >> 1) + 1 <= R)
      up(L, R, val, ((l + r) >> 1) + 1, r, (rt << 1 | 1));
    pushup(rt);
  }
}
int f(int l, int r, int rt) {
  if (l == r)
    return l;
  else {
    pushdown(rt);
    if (mx[(rt << 1 | 1)] > 0)
      return f(((l + r) >> 1) + 1, r, (rt << 1 | 1));
    else
      return f(l, ((l + r) >> 1), (rt << 1));
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    up(1, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    up(1, b[i], -1);
  }
  cin >> q;
  while (q--) {
    int x, y, z;
    cin >> x >> y >> z;
    if (x == 1) {
      up(1, a[y], -1);
      up(1, z, 1);
      a[y] = z;
    } else {
      up(1, b[y], 1);
      up(1, z, -1);
      b[y] = z;
    }
    if (mx[1] > 0)
      cout << f(1, 1e6, 1) << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
