#include <bits/stdc++.h>
template <class T>
inline T read(const T sample) {
  T x = 0;
  int f = 1;
  char s;
  while ((s = getchar()) > '9' || s < '0')
    if (s == '-') f = -1;
  while (s >= '0' && s <= '9')
    x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();
  return x * f;
}
template <class T>
inline void write(const T x) {
  if (x < 0) return (void)(putchar('-'), write(-x));
  if (x > 9) write(x / 10);
  putchar(x % 10 ^ 48);
}
template <class T>
inline T Max(const T x, const T y) {
  return x > y ? x : y;
}
template <class T>
inline T Min(const T x, const T y) {
  return x < y ? x : y;
}
template <class T>
inline T fab(const T x) {
  return x > 0 ? x : -x;
}
template <class T>
inline T Gcd(const T x, const T y) {
  return y ? Gcd(y, x % y) : x;
}
const int N = 3e5 + 5, Val = 1e6;
int n, m, a[N], b[N], la[Val << 2], s[Val << 2];
void pushDown(int o) {
  if (!la[o]) return;
  int l = (o << 1), r = (o << 1 | 1);
  la[l] += la[o], la[r] += la[o];
  s[l] += la[o], s[r] += la[o];
  la[o] = 0;
}
void modify(int o, int l, int r, int L, int R, int k) {
  if (l > R || r < L) return;
  if (l >= L && r <= R) {
    s[o] += k, la[o] += k;
    return;
  }
  int mid = l + r >> 1;
  pushDown(o);
  modify(o << 1, l, mid, L, R, k);
  modify(o << 1 | 1, mid + 1, r, L, R, k);
  s[o] = Max(s[o << 1], s[o << 1 | 1]);
}
int query(int o, int l, int r) {
  if (l == r) return l;
  int mid = l + r >> 1;
  pushDown(o);
  if (s[o << 1 | 1] > 0) return query(o << 1 | 1, mid + 1, r);
  return query(o << 1, l, mid);
}
int main() {
  int op, x, y;
  n = read(9), m = read(9);
  for (register signed i = (1), _end = (n); i <= _end; ++i)
    a[i] = read(9), modify(1, 1, Val, 1, a[i], 1);
  for (register signed i = (1), _end = (m); i <= _end; ++i)
    b[i] = read(9), modify(1, 1, Val, 1, b[i], -1);
  for (int t = read(9); t; --t) {
    op = read(9), x = read(9), y = read(9);
    if (op == 1) {
      modify(1, 1, Val, 1, a[x], -1);
      modify(1, 1, Val, 1, y, 1);
      a[x] = y;
    } else {
      modify(1, 1, Val, 1, b[x], 1);
      modify(1, 1, Val, 1, y, -1);
      b[x] = y;
    }
    if (s[1] > 0)
      write(query(1, 1, Val)), putchar('\n');
    else
      puts("-1");
  }
  return 0;
}
