#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const int INF = (int)1e9;
int n, m, q, op, p, x, a[N], b[N], tree[4 * N], lazy[4 * N];
void down(int root) {
  if (lazy[root] != 0) {
    lazy[root * 2 + 1] += lazy[root];
    lazy[root * 2 + 2] += lazy[root];
    tree[root * 2 + 1] += lazy[root];
    tree[root * 2 + 2] += lazy[root];
    lazy[root] = 0;
  }
}
void update(int root, int rl, int rr, int l, int r, int by) {
  if (l > r) {
    return;
  }
  if (l <= rl && rr <= r) {
    lazy[root] += by;
    tree[root] += by;
    return;
  }
  down(root);
  int rm = (rl + rr) / 2;
  update(root * 2 + 1, rl, rm, l, min(r, rm), by);
  update(root * 2 + 2, rm + 1, rr, max(l, rm + 1), r, by);
  tree[root] = max(tree[root * 2 + 1], tree[root * 2 + 2]);
}
int ask(int root, int rl, int rr) {
  if (tree[root] <= 0) {
    return -1;
  }
  if (rl == rr) {
    return rl;
  }
  int rm = (rl + rr) / 2;
  down(root);
  if (tree[root * 2 + 2] > 0) {
    return ask(root * 2 + 2, rm + 1, rr);
  } else {
    return ask(root * 2 + 1, rl, rm);
  }
}
int main() {
  memset(lazy, 0, sizeof lazy);
  memset(tree, 0, sizeof tree);
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    update(0, 0, N - 1, 0, a[i], 1);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
    update(0, 0, N - 1, 0, b[i], -1);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d %d %d", &op, &p, &x);
    p--;
    if (op == 1) {
      update(0, 0, N - 1, 0, a[p], -1);
      a[p] = x;
      update(0, 0, N - 1, 0, a[p], 1);
    } else if (op == 2) {
      update(0, 0, N - 1, 0, b[p], 1);
      b[p] = x;
      update(0, 0, N - 1, 0, b[p], -1);
    }
    printf("%d\n", ask(0, 0, N - 1));
  }
  return 0;
}
