#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 19, maxn = 1e6;
int m, n, q, A[N], B[N];
struct date {
  int val, det;
  date() { val = det = 0; }
  void mdf(int v) {
    val += v;
    det += v;
  }
  void download(date &A, date &B) {
    A.mdf(det);
    B.mdf(det);
    det = 0;
    val = min(A.val, B.val);
  }
  bool ok() { return val < 0; }
};
struct node {
  node *c[2];
  date val;
  void update() {
    if (c[0] && c[1]) val.download(c[0]->val, c[1]->val);
  }
  void mdf(int v) { val.mdf(v); }
  bool ok() { return val.ok(); }
} Pool[N * 4 + 19], *rt;
int TOP;
node *NEW() { return Pool + TOP++; }
node *build(int l, int r) {
  node *rt = NEW();
  if (l == r) return rt;
  int mid = l + r >> 1;
  rt->c[0] = build(l, mid);
  rt->c[1] = build(mid + 1, r);
  return rt;
}
void mdf(node *rt, int l, int r, int ql, int qr, int v) {
  if (ql > r || qr < l) return;
  rt->update();
  if (ql <= l && qr >= r) {
    rt->mdf(v);
    return;
  }
  int mid = l + r >> 1;
  mdf(rt->c[0], l, mid, ql, qr, v);
  mdf(rt->c[1], mid + 1, r, ql, qr, v);
  rt->update();
}
int ask(node *rt, int l, int r) {
  rt->update();
  if (l == r) return l;
  int mid = l + r >> 1;
  if (rt->c[1]->ok()) return ask(rt->c[1], mid + 1, r);
  if (rt->c[0]->ok()) return ask(rt->c[0], l, mid);
  return -1;
}
int main() {
  scanf("%d%d", &n, &m);
  rt = build(1, maxn);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    A[i] = x;
    mdf(rt, 1, maxn, 1, x, -1);
  }
  for (int i = 1; i <= m; ++i) {
    int x;
    scanf("%d", &x);
    B[i] = x;
    mdf(rt, 1, maxn, 1, x, 1);
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      mdf(rt, 1, maxn, 1, A[x], 1);
      mdf(rt, 1, maxn, 1, y, -1);
      A[x] = y;
      printf("%d\n", ask(rt, 1, maxn));
    } else {
      mdf(rt, 1, maxn, 1, B[x], -1);
      mdf(rt, 1, maxn, 1, y, 1);
      B[x] = y;
      printf("%d\n", ask(rt, 1, maxn));
    }
  }
  return 0;
}
