#include <bits/stdc++.h>
using namespace std;
const int N = int(3e5) + 7;
const int M = int(1e6) + 1;
const int inf = int(1e9);
int sum[M << 2], MinDiff[M << 2], l[M << 2], h[M << 2];
int n, m, a[N], b[N], q;
void Build(int x, int low, int high) {
  l[x] = low, h[x] = high;
  if (l[x] == h[x]) return;
  int mid = (low + high) >> 1;
  Build(x << 1, low, mid);
  Build(x << 1 | 1, mid + 1, high);
}
void Update(int x, int pos, int val) {
  if (l[x] > pos || h[x] < pos) return;
  if (pos <= l[x] && h[x] <= pos) {
    sum[x] += val;
    MinDiff[x] += val;
    return;
  }
  Update(x << 1, pos, val);
  Update(x << 1 | 1, pos, val);
  sum[x] = sum[x << 1 | 1] + sum[x << 1];
  MinDiff[x] = min(MinDiff[x << 1] + sum[x << 1 | 1], MinDiff[x << 1 | 1]);
}
int Query(int x, int ss) {
  if (l[x] == h[x]) {
    if (ss + sum[x] < 0) return l[x];
    return -1;
  }
  if (MinDiff[x << 1 | 1] + ss < 0) return Query(x << 1 | 1, ss);
  return Query(x << 1, ss + sum[x << 1 | 1]);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  if (fopen("test"
            ".inp",
            "r")) {
    freopen(
        "test"
        ".inp",
        "r", stdin);
    freopen(
        "test"
        ".out",
        "w", stdout);
  }
  cin >> n >> m;
  Build(1, 1, int(1e6));
  for (int i = 1; i <= n; ++i) cin >> a[i], Update(1, a[i], -1);
  for (int i = 1; i <= m; ++i) cin >> b[i], Update(1, b[i], 1);
  cin >> q;
  while (q--) {
    int cmd, x, y;
    cin >> cmd >> x >> y;
    if (cmd == 1) {
      Update(1, a[x], 1);
      Update(1, a[x] = y, -1);
    } else {
      Update(1, b[x], -1);
      Update(1, b[x] = y, 1);
    }
    cout << Query(1, 0) << '\n';
  }
}
