#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3 * 100100, MAXA = 1001000;
int n, m, q, a[MAXN], b[MAXN];
struct no {
  no *l, *r;
  int beg, end, mid, sum, mnp, mnpos;
  no(int beg, int end)
      : beg(beg), end(end), mid((beg + end) >> 1), sum(0), mnp(0), mnpos(end) {
    if (beg != end) l = new no(beg, mid), r = new no(mid + 1, end);
  }
  ~no() {
    if (beg != end) delete l, delete r;
  }
  void upd(int pos, int val) {
    if (beg == end) return void((sum += val, mnp += val));
    (pos <= mid ? l : r)->upd(pos, val);
    sum = l->sum + r->sum;
    if (l->sum + r->mnp <= l->mnp)
      mnp = l->sum + r->mnp, mnpos = r->mnpos;
    else
      mnp = l->mnp, mnpos = l->mnpos;
  }
};
int main() {
  scanf("%d %d", &n, &m);
  no seg(1, MAXA);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), seg.upd(a[i], 1);
  for (int i = 1; i <= m; ++i) scanf("%d", &b[i]), seg.upd(b[i], -1);
  int x, y, z;
  for (scanf("%d", &q); q--;) {
    scanf("%d %d %d", &x, &y, &z);
    if (x == 1) {
      seg.upd(a[y], -1);
      a[y] = z;
      seg.upd(a[y], 1);
    } else if (x == 2) {
      seg.upd(b[y], 1);
      b[y] = z;
      seg.upd(b[y], -1);
    }
    printf("%d\n", (seg.mnpos + 1 <= MAXA ? seg.mnpos + 1 : -1));
  }
}
