#include <bits/stdc++.h>
using namespace std;
int mx[1000010 << 2], tag[1000010 << 2];
char *p1, *p2, buf[100000];
int rd() {
  int x = 0, f = 1;
  char c =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
           ? EOF
           : *p1++);
  while (c < 48) {
    if (c == '-') f = -1;
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  while (c > 47) {
    x = (((x << 2) + x) << 1) + (c ^ 48),
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  return x * f;
}
inline void pushup(int p) { mx[p] = max(mx[p << 1], mx[p << 1 | 1]); }
inline void pushdown(int p) {
  if (tag[p]) {
    mx[p << 1] += tag[p], tag[p << 1] += tag[p];
    mx[p << 1 | 1] += tag[p], tag[p << 1 | 1] += tag[p];
    tag[p] = 0;
  }
}
void update(int x, int y, int v, int l, int r, int p) {
  if (x <= l && r <= y) {
    tag[p] += v;
    mx[p] += v;
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(p);
  if (x <= mid) {
    update(x, y, v, l, mid, p << 1);
  }
  if (mid < y) {
    update(x, y, v, mid + 1, r, p << 1 | 1);
  }
  pushup(p);
}
int query(int l, int r, int p) {
  if (l == r) {
    return l;
  }
  int mid = (l + r) >> 1;
  pushdown(p);
  if (mx[p << 1 | 1] > 0) {
    return query(mid + 1, r, p << 1 | 1);
  } else {
    return query(l, mid, p << 1);
  }
}
int a[1000010], b[1000010];
int main() {
  int n = rd(), m = rd();
  for (int i = 1; i <= n; i++) {
    a[i] = rd();
    update(1, a[i], 1, 1, 1e6, 1);
  }
  for (int i = 1; i <= m; i++) {
    b[i] = rd();
    update(1, b[i], -1, 1, 1e6, 1);
  }
  int q = rd();
  while (q--) {
    int opt = rd(), x = rd(), y = rd();
    if (opt == 1) {
      update(1, a[x], -1, 1, 1e6, 1);
      a[x] = y;
      update(1, a[x], 1, 1, 1e6, 1);
    } else {
      update(1, b[x], 1, 1, 1e6, 1);
      b[x] = y;
      update(1, b[x], -1, 1, 1e6, 1);
    }
    if (mx[1] <= 0) {
      puts("-1");
    } else {
      printf("%d\n", query(1, 1e6, 1));
    }
  }
  return 0;
}
