#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1000010;
namespace Aint {
int aint[4 * NMAX];
int smax[4 * NMAX];
int l, r, val, n = 1000000;
void update(int nod = 1, int st = 1, int dr = n) {
  if (l > dr || r < st) return;
  if (l <= st && r >= dr) {
    aint[nod] += val;
    smax[nod] += val;
  } else {
    update(2 * nod, st, (st + dr) / 2);
    update(2 * nod + 1, (st + dr) / 2 + 1, dr);
    smax[nod] = aint[nod] + max(smax[2 * nod], smax[2 * nod + 1]);
  }
}
int cbin(int nod = 1, int st = 1, int dr = n, int sup = 0) {
  if (st == dr) return (aint[nod] + sup > 0 ? st : 0);
  if (smax[nod] + sup <= 0) return 0;
  int a = cbin(2 * nod + 1, (st + dr) / 2 + 1, dr, sup + aint[nod]);
  if (!a) return cbin(2 * nod, st, (st + dr) / 2, sup + aint[nod]);
  return a;
}
}  // namespace Aint
int a[NMAX], b[NMAX];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    Aint::l = 1, Aint::r = a[i], Aint::val = 1;
    Aint::update();
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", b + i);
    Aint::l = 1, Aint::r = b[i], Aint::val = -1;
    Aint::update();
  }
  int q, t, x, y;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      Aint::l = 1, Aint::r = a[x];
      Aint::val = -1;
      Aint::update();
      a[x] = y;
      Aint::l = 1, Aint::r = a[x];
      Aint::val = 1;
      Aint::update();
    } else {
      Aint::l = 1, Aint::r = b[x];
      Aint::val = 1;
      Aint::update();
      b[x] = y;
      Aint::l = 1, Aint::r = b[x];
      Aint::val = -1;
      Aint::update();
    }
    int ans = Aint::cbin();
    if (!ans) ans = -1;
    printf("%d\n", ans);
  }
  return 0;
}
