#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
int f[MAXN * 4], lz[MAXN * 4], n, m, a[300005], b[300005];
void push(int x, int l, int r) {
  if (lz[x] == 0) return;
  f[x] += lz[x];
  if (l != r) {
    lz[x * 2] += lz[x];
    lz[x * 2 + 1] += lz[x];
  }
  lz[x] = 0;
}
void upd(int x, int l, int r, int ll, int rr, int val) {
  push(x, l, r);
  if (l > rr || r < ll) return;
  if (l >= ll && r <= rr) {
    lz[x] += val;
    push(x, l, r);
    return;
  }
  int md = (l + r) / 2;
  upd(x * 2, l, md, ll, rr, val);
  upd(x * 2 + 1, md + 1, r, ll, rr, val);
  f[x] = min(f[x * 2], f[x * 2 + 1]);
}
int que(int x, int l, int r) {
  push(x, l, r);
  if (f[x] >= 0) return -1;
  if (l == r) return l;
  int md = (l + r) / 2;
  int rx = que(x * 2 + 1, md + 1, r);
  if (rx != -1) return rx;
  return que(x * 2, l, md);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    upd(1, 1, MAXN - 1, 1, a[i], -1);
  }
  for (int i = 1; i <= m; ++i) {
    cin >> b[i];
    upd(1, 1, MAXN - 1, 1, b[i], 1);
  }
  int q, q1, q2, q3;
  cin >> q;
  while (q--) {
    cin >> q1 >> q2 >> q3;
    if (q1 == 1) {
      upd(1, 1, MAXN - 1, 1, a[q2], 1);
      a[q2] = q3;
      upd(1, 1, MAXN - 1, 1, a[q2], -1);
    } else {
      upd(1, 1, MAXN - 1, 1, b[q2], -1);
      b[q2] = q3;
      upd(1, 1, MAXN - 1, 1, b[q2], 1);
    }
    cout << que(1, 1, MAXN - 1) << '\n';
  }
}
