#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3 * 100100, MAXA = 1001000;
int n, m, q, v[2][MAXN];
struct no {
  no *l, *r;
  int beg, end, mid, sum, mxsfx;
  no(int beg, int end)
      : beg(beg), end(end), mid((beg + end) >> 1), sum(0), mxsfx(0) {
    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, mxsfx += val));
    (pos <= mid ? l : r)->upd(pos, val);
    sum = l->sum + r->sum;
    mxsfx = max(l->mxsfx + r->sum, r->mxsfx);
  }
  int get(int offset = 0) {
    if (beg == end) return beg;
    if (r->mxsfx > offset) return r->get(offset);
    if (l->mxsfx + r->sum <= offset) return -1;
    return l->get(offset - r->sum);
  }
};
int main() {
  scanf("%d %d", &n, &m);
  no seg(1, MAXA);
  for (int i = 1; i <= n; ++i) scanf("%d", &v[0][i]), seg.upd(v[0][i], 1);
  for (int i = 1; i <= m; ++i) scanf("%d", &v[1][i]), seg.upd(v[1][i], -1);
  int x, y, z;
  for (scanf("%d", &q); q--;) {
    scanf("%d %d %d", &x, &y, &z), x--;
    seg.upd(v[x][y], (x == 0 ? -1 : 1));
    v[x][y] = z;
    seg.upd(v[x][y], (x == 0 ? 1 : -1));
    printf("%d\n", seg.get());
  }
}
