#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 239;
namespace SegmentTree {
struct Segment {
  int sum;
  int max_suff;
  Segment(int sum_, int max_suff_) {
    sum = sum_;
    max_suff = max_suff_;
  }
  Segment(int x) {
    sum = x;
    max_suff = max(x, 0);
  }
  Segment() {
    sum = -1;
    max_suff = -1;
  }
  friend Segment conq(const Segment &l, const Segment &r) {
    return Segment(l.sum + r.sum, max(l.max_suff + r.sum, r.max_suff));
  }
};
int a[MAXN];
Segment t[4 * MAXN];
void pull(int v) { t[v] = conq(t[2 * v + 1], t[2 * v + 2]); }
void build(int v, int l, int r) {
  if (l + 1 == r) {
    t[v] = Segment(0);
  } else {
    int m = (r + l) >> 1;
    build(2 * v + 1, l, m);
    build(2 * v + 2, m, r);
    pull(v);
  }
}
void add(int v, int l, int r, int pos, int val) {
  if (l + 1 == r) {
    assert(l == pos);
    t[v] = Segment(a[l] + val);
    a[l] += val;
  } else {
    int m = (r + l) >> 1;
    if (pos < m) {
      add(2 * v + 1, l, m, pos, val);
    } else {
      add(2 * v + 2, m, r, pos, val);
    }
    pull(v);
  }
}
int go_down(int v, int l, int r, int sum) {
  if (l + 1 == r) {
    return l;
  } else {
    int m = (r + l) >> 1;
    if (t[2 * v + 2].max_suff + sum > 0) {
      return go_down(2 * v + 2, m, r, sum);
    } else {
      return go_down(2 * v + 1, l, m, sum + t[2 * v + 2].sum);
    }
  }
}
void add(int pos, int val) { add(0, 0, MAXN, pos, val); }
void init() { build(0, 0, MAXN); }
int get() {
  if (t[0].max_suff <= 0) {
    return -1;
  } else {
    return go_down(0, 0, MAXN, 0);
  }
}
}  // namespace SegmentTree
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  SegmentTree::init();
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (auto &t : a) {
    cin >> t;
    SegmentTree::add(t, 1);
  }
  vector<int> b(m);
  for (auto &t : b) {
    cin >> t;
    SegmentTree::add(t, -1);
  }
  int q;
  cin >> q;
  while (q--) {
    int tp, i, x;
    cin >> tp >> i >> x;
    i--;
    if (tp == 1) {
      SegmentTree::add(a[i], -1);
      a[i] = x;
      SegmentTree::add(a[i], 1);
    } else {
      SegmentTree::add(b[i], 1);
      b[i] = x;
      SegmentTree::add(b[i], -1);
    }
    cout << SegmentTree::get() << '\n';
  }
}
