#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9')
    s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return s * w;
}
struct SEG {
  int Max, lazy;
} tr[600010 << 2];
int n, m, q;
int a[600010], b[600010];
void update(int x) { tr[x].Max = max(tr[x << 1].Max, tr[x << 1 | 1].Max); }
void pusha(int x, int val) { tr[x].Max += val, tr[x].lazy += val; }
void pushdown(int x) {
  if (tr[x].lazy != 0)
    pusha(x << 1, tr[x].lazy), pusha(x << 1 | 1, tr[x].lazy), tr[x].lazy = 0;
}
void modify(int x, int l, int r, int ql, int qr, int val) {
  if (ql <= l && r <= qr) return pusha(x, val), void();
  int mid = (l + r) >> 1;
  pushdown(x);
  if (ql <= mid) modify(x << 1, l, mid, ql, qr, val);
  if (mid < qr) modify(x << 1 | 1, mid + 1, r, ql, qr, val);
  update(x);
}
int query(int x, int l, int r) {
  if (tr[x].Max <= 0) return -1;
  if (l == r) return l;
  int mid = (l + r) >> 1;
  pushdown(x);
  return tr[x << 1 | 1].Max > 0 ? query(x << 1 | 1, mid + 1, r)
                                : query(x << 1, l, mid);
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= m; i++) b[i] = read();
  q = read();
  for (int i = 1; i <= n; i++) modify(1, 1, 1000000, 1, a[i], 1);
  for (int i = 1; i <= m; i++) modify(1, 1, 1000000, 1, b[i], -1);
  while (q--) {
    int opt = read(), x = read(), y = read();
    if (opt == 1)
      modify(1, 1, 1000000, 1, a[x], -1), a[x] = y,
                                          modify(1, 1, 1000000, 1, a[x], 1);
    else
      modify(1, 1, 1000000, 1, b[x], 1), b[x] = y,
                                         modify(1, 1, 1000000, 1, b[x], -1);
    printf("%d\n", query(1, 1, 1000000));
  }
  return 0;
}
