#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int n, m;
const int N = 6e5 + 5;
int a[N], b[N], v[3 * N];
int sum;
struct Que {
  int ty, p, val;
} q[N];
long long lazy[N << 2];
struct Tree {
  int l, r;
  long long sum;
  int mid() { return (l + r) >> 1; }
} tree[N << 2];
void PushUp(int rt) {
  tree[rt].sum = max(tree[rt << 1].sum, tree[rt << 1 | 1].sum);
}
void PushDown(int rt, int m) {
  if (lazy[rt] != 0) {
    lazy[rt << 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    tree[rt << 1].sum += lazy[rt];
    tree[rt << 1 | 1].sum += lazy[rt];
    lazy[rt] = 0;
  }
}
void build(int l, int r, int rt) {
  tree[rt].l = l;
  tree[rt].r = r;
  lazy[rt] = 0;
  if (l == r) {
    tree[rt].sum = 0;
    return;
  }
  int m = tree[rt].mid();
  build(l, m, (rt << 1));
  build(m + 1, r, (rt << 1 | 1));
  PushUp(rt);
}
void update(int c, int l, int r, int rt) {
  if (tree[rt].l == l && tree[rt].r == r) {
    lazy[rt] += c;
    tree[rt].sum += c;
    return;
  }
  if (tree[rt].l == tree[rt].r) return;
  int m = tree[rt].mid();
  PushDown(rt, tree[rt].r - tree[rt].l + 1);
  if (r <= m)
    update(c, l, r, rt << 1);
  else if (l > m)
    update(c, l, r, rt << 1 | 1);
  else {
    update(c, l, m, rt << 1);
    update(c, m + 1, r, rt << 1 | 1);
  }
  PushUp(rt);
}
long long Query(int l, int r, int rt) {
  if (tree[rt].l == tree[rt].r) {
    return tree[rt].l;
  }
  int m = tree[rt].mid();
  PushDown(rt, tree[rt].r - tree[rt].l + 1);
  if (tree[rt << 1 | 1].sum > 0)
    return Query(m + 1, r, rt << 1 | 1);
  else
    return Query(l, m, rt << 1);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    v[++sum] = a[i];
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    v[++sum] = b[i];
  }
  int Q;
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    scanf("%d %d %d", &q[i].ty, &q[i].p, &q[i].val);
    v[++sum] = q[i].val;
  }
  sort(v + 1, v + 1 + sum);
  sum = unique(v + 1, v + 1 + sum) - v - 1;
  for (int i = 1; i <= n; i++) a[i] = lower_bound(v + 1, v + sum + 1, a[i]) - v;
  for (int i = 1; i <= m; i++) b[i] = lower_bound(v + 1, v + sum + 1, b[i]) - v;
  for (int i = 1; i <= Q; i++)
    q[i].val = lower_bound(v + 1, v + sum + 1, q[i].val) - v;
  build(1, sum, 1);
  for (int i = 1; i <= n; i++) update(1, 1, a[i], 1);
  for (int i = 1; i <= m; i++) update(-1, 1, b[i], 1);
  for (int i = 1; i <= Q; i++) {
    if (q[i].ty == 1) {
      update(-1, 1, a[q[i].p], 1);
      a[q[i].p] = q[i].val;
      update(1, 1, a[q[i].p], 1);
    } else {
      update(1, 1, b[q[i].p], 1);
      b[q[i].p] = q[i].val;
      update(-1, 1, b[q[i].p], 1);
    }
    if (tree[1].sum <= 0)
      printf("-1\n");
    else
      printf("%d\n", v[Query(1, sum, 1)]);
  }
  return 0;
}
