#include <bits/stdc++.h>
using namespace std;
const int N = 1e6, M = N << 2;
int n, m, q, valA[N], valB[N], buc[N + 10], lt[M], rt[M], minVal[M], add[M];
inline void pushdown(int);
template <class T>
inline void read(T &x) {
  x = 0;
  char ch = getchar(), w = 0;
  while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = w ? -x : x;
  return;
}
void build(int k) {
  if (lt[k] == rt[k]) {
    minVal[k] = buc[lt[k]];
    return;
  }
  int mid = (lt[k] + rt[k]) >> 1, l = k << 1, r = (k << 1) + 1;
  lt[l] = lt[k], rt[l] = mid, lt[r] = mid + 1, rt[r] = rt[k];
  build(l), build(r), minVal[k] = min(minVal[l], minVal[r]);
  return;
}
inline void modify(int k, int x, int y, int w) {
  if (x > y) return;
  if (lt[k] >= x && rt[k] <= y) {
    minVal[k] += w, add[k] += w;
    return;
  }
  pushdown(k);
  int mid = (lt[k] + rt[k]) >> 1, l = k << 1, r = (k << 1) + 1;
  if (x <= mid) modify(l, x, y, w);
  if (y > mid) modify(r, x, y, w);
  minVal[k] = min(minVal[l], minVal[r]);
  return;
}
inline int query(int k) {
  if (minVal[k] >= 0) return -1;
  if (lt[k] == rt[k]) return lt[k];
  pushdown(k);
  int l = k << 1, r = (k << 1) + 1;
  return query(minVal[r] < 0 ? r : l);
}
inline void pushdown(int k) {
  int l = k << 1, r = (k << 1) + 1;
  if (add[k]) {
    modify(l, lt[k], rt[k], add[k]);
    modify(r, lt[k], rt[k], add[k]);
    add[k] = 0;
  }
  return;
}
int main() {
  int opt, x, y;
  read(n), read(m);
  for (register int i = 1; i <= n; ++i) read(valA[i]), --buc[valA[i]];
  for (register int i = 1; i <= m; ++i) read(valB[i]), ++buc[valB[i]];
  for (register int i = N - 1; i; --i) buc[i] += buc[i + 1];
  lt[1] = 1, rt[1] = N, build(1);
  read(q);
  while (q--) {
    read(opt), read(x), read(y);
    if (opt == 1)
      modify(1, min(valA[x], y) + 1, max(valA[x], y), valA[x] <= y ? -1 : 1),
          valA[x] = y;
    else
      modify(1, min(valB[x], y) + 1, max(valB[x], y), valB[x] <= y ? 1 : -1),
          valB[x] = y;
    printf("%d\n", query(1));
  }
  return 0;
}
