#include <bits/stdc++.h>
using namespace std;
struct seg {
  int l, r, v = 0, id, lz = 0;
  seg *ch[2]{};
  seg(int _l, int _r) : l(_l), r(_r), id(_r - 1) {
    if (l < r - 1)
      ch[0] = new seg(l, l + r >> 1), ch[1] = new seg(l + r >> 1, r);
  }
  void modify(int _r, int d) {
    if (r <= _r) {
      lz += d, v += d;
      return;
    }
    push();
    ch[0]->modify(_r, d);
    if (l + r >> 1 < _r) ch[1]->modify(_r, d);
    pull();
  }
  void push() {
    ch[0]->v += lz, ch[0]->lz += lz, ch[1]->v += lz, ch[1]->lz += lz, lz = 0;
  }
  void pull() {
    if (ch[1]->v > 0)
      id = ch[1]->id, v = ch[1]->v;
    else
      id = ch[ch[1]->v >= ch[0]->v]->id, v = max(ch[0]->v, ch[1]->v);
  }
} rt(0, 1000001);
int main() {
  int n, m;
  cin >> n >> m;
  int a[n], b[m];
  for (int &i : a) cin >> i, rt.modify(i, 1);
  for (int &i : b) cin >> i, rt.modify(i, -1);
  int q;
  cin >> q;
  while (q--) {
    int ty, i, x;
    cin >> ty >> i >> x;
    --i, ++x;
    if (ty == 1) {
      rt.modify(a[i], -1);
      a[i] = x;
      rt.modify(a[i], 1);
    } else {
      rt.modify(b[i], 1);
      b[i] = x;
      rt.modify(b[i], -1);
    }
    cout << (rt.v > 0 ? rt.id : -1) << '\n';
  }
}
