#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
struct SegmentTreeLPMin {
  int n, h;
  vector<int> t, d;
  SegmentTreeLPMin(vector<int> v) {
    n = v.size();
    h = sizeof(int) * 8 - __builtin_clz(n);
    t.resize(2 * n);
    d.resize(n);
    for (int i = 0; i < n; i++) {
      t[i + n] = v[i];
    }
    for (int i = n - 1; i > 0; i--) {
      t[i] = min(t[i << 1], t[i << 1 | 1]);
    }
  }
  void apply(int p, int value) {
    t[p] += value;
    if (p < n) d[p] += value;
  }
  void build(int p) {
    while (p > 1) p >>= 1, t[p] = min(t[p << 1], t[p << 1 | 1]) + d[p];
  }
  void push(int p) {
    for (int s = h; s > 0; --s) {
      int i = p >> s;
      if (d[i] != 0) {
        apply(i << 1, d[i]);
        apply(i << 1 | 1, d[i]);
        d[i] = 0;
      }
    }
  }
  void inc(int l, int r, int value) {
    l += n, r += n;
    int l0 = l, r0 = r;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) apply(l++, value);
      if (r & 1) apply(--r, value);
    }
    build(l0);
    build(r0 - 1);
  }
  int query(int l, int r) {
    l += n, r += n;
    push(l);
    push(r - 1);
    int res = 2e9;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = min(res, t[l++]);
      if (r & 1) res = min(t[--r], res);
    }
    return res;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  SegmentTreeLPMin st(vector<int>(1000000));
  vector<int> a(n + 1), b(m + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    st.inc(0, a[i] + 1, -1);
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    st.inc(0, b[i] + 1, 1);
  }
  int q;
  cin >> q;
  while (q--) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      st.inc(0, a[x] + 1, 1);
      st.inc(0, y + 1, -1);
      a[x] = y;
    } else {
      st.inc(0, b[x] + 1, -1);
      st.inc(0, y + 1, 1);
      b[x] = y;
    }
    int l = 0, r = 1000000;
    while (l < r) {
      int mid = (l + r) / 2;
      if (st.query(mid + 1, 1000001) < 0)
        l = mid + 1;
      else
        r = mid;
    }
    cout << (l ? l : -1) << '\n';
  }
  return 0;
}
