#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 10;
class Seg {
  int l, m, r;
  Seg* ch[2];
  int ma = 0, tag = 0;
  void pull() { ma = max(ch[0]->ma, ch[1]->ma); }
  void push() {
    if (tag) {
      for (int i : {0, 1}) {
        ch[i]->ma += tag;
        ch[i]->tag += tag;
      }
      tag = 0;
    }
  }

 public:
  Seg(int l, int r) : l(l), r(r), m(l + r >> 1) {
    if (r - l > 1) {
      ch[0] = new Seg(l, m);
      ch[1] = new Seg(m, r);
    }
  }
  void add(int ql, int qr, int val) {
    if (ql <= l and r <= qr)
      tag += val, ma += val;
    else {
      push();
      if (ql < m) ch[0]->add(ql, qr, val);
      if (m < qr) ch[1]->add(ql, qr, val);
      pull();
    }
  }
  int query_idx() {
    if (ma <= 0)
      return -1;
    else if (r - l == 1)
      return l;
    else {
      push();
      int ans = ch[1]->query_idx();
      if (ans == -1) ans = ch[0]->query_idx();
      pull();
      return ans;
    }
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> A(n), B(m);
  Seg root(0, 1 << 20);
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    root.add(0, A[i] + 1, +1);
  }
  for (int i = 0; i < m; ++i) {
    cin >> B[i];
    root.add(0, B[i] + 1, -1);
  }
  int q;
  cin >> q;
  while (q--) {
    int t, i, x;
    cin >> t >> i >> x;
    --i;
    if (t == 1) {
      root.add(0, A[i] + 1, -1);
      A[i] = x;
      root.add(0, A[i] + 1, +1);
    } else {
      root.add(0, B[i] + 1, +1);
      B[i] = x;
      root.add(0, B[i] + 1, -1);
    }
    cout << root.query_idx() << '\n';
  }
}
