#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
struct cxk {
  int l, r, maxx, lazy;
} tree[maxn << 2];
int n, m, a[maxn], b[maxn], q;
void pushup(int x) {
  tree[x].maxx = max(tree[x << 1].maxx, tree[x << 1 | 1].maxx);
}
void pushdown(int x) {
  if (tree[x].lazy) {
    tree[x << 1].lazy += tree[x].lazy;
    tree[x << 1 | 1].lazy += tree[x].lazy;
    tree[x << 1].maxx += tree[x].lazy;
    tree[x << 1 | 1].maxx += tree[x].lazy;
    tree[x].lazy = 0;
  }
}
void build(int x, int l, int r) {
  tree[x].l = l;
  tree[x].r = r;
  tree[x].lazy = 0;
  if (l == r) {
    tree[x].maxx = 0;
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  pushup(x);
}
void update(int x, int l, int r, int val) {
  if (l <= tree[x].l && tree[x].r <= r) {
    tree[x].maxx += val;
    tree[x].lazy += val;
    return;
  }
  pushdown(x);
  int mid = (tree[x].l + tree[x].r) >> 1;
  if (l <= mid) update(x << 1, l, r, val);
  if (mid < r) update(x << 1 | 1, l, r, val);
  pushup(x);
}
int query(int x) {
  if (tree[x].l == tree[x].r) return tree[x].l;
  pushdown(x);
  int mid = (tree[x].l + tree[x].r) >> 1;
  if (tree[x << 1 | 1].maxx > 0) return query(x << 1 | 1);
  return query(x << 1);
}
int main() {
  scanf("%d%d", &n, &m);
  build(1, 1, maxn);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), update(1, 1, a[i], 1);
  for (int i = 1; i <= m; ++i) scanf("%d", &b[i]), update(1, 1, b[i], -1);
  scanf("%d", &q);
  while (q--) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      update(1, 1, a[x], -1);
      a[x] = y;
      update(1, 1, a[x], 1);
    } else {
      update(1, 1, b[x], 1);
      b[x] = y;
      update(1, 1, b[x], -1);
    }
    if (tree[x].maxx <= 0)
      puts("-1");
    else
      printf("%d\n", query(1));
  }
}
