#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 1e6 + 10;
const int M = 1e6 + 10;
int n, m, q, a[N], b[N];
int tr[N << 2], tag[N << 2];
void pd(int o) {
  if (tag[o]) {
    tr[(o << 1)] += tag[o];
    tr[((o << 1) | 1)] += tag[o];
    tag[(o << 1)] += tag[o];
    tag[((o << 1) | 1)] += tag[o];
    tag[o] = 0;
  }
}
void upd(int o, int l, int r, int first, int v) {
  if (r <= first) {
    tr[o] += v;
    tag[o] += v;
    return;
  }
  pd(o);
  upd((o << 1), l, ((l + r) >> 1), first, v);
  if (((l + r) >> 1) < first)
    upd(((o << 1) | 1), ((l + r) >> 1) + 1, r, first, v);
  tr[o] = max(tr[(o << 1)], tr[((o << 1) | 1)]);
}
int find(int o, int l, int r) {
  if (tr[o] <= 0) return -1;
  if (l == r) return l;
  pd(o);
  int t = find(((o << 1) | 1), ((l + r) >> 1) + 1, r);
  return t < 0 ? find((o << 1), l, ((l + r) >> 1)) : t;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i), upd(1, 1, M, a[i], 1);
  for (int i = 1; i <= m; ++i) scanf("%d", b + i), upd(1, 1, M, b[i], -1);
  scanf("%d", &q);
  while (q--) {
    int op, first, second;
    scanf("%d%d%d", &op, &first, &second);
    if (op == 1)
      upd(1, 1, M, a[first], -1), a[first] = second, upd(1, 1, M, a[first], 1);
    else
      upd(1, 1, M, b[first], 1), b[first] = second, upd(1, 1, M, b[first], -1);
    printf("%d\n", find(1, 1, M));
  }
}
