#include <bits/stdc++.h>
using namespace std;
int const N = 300000, M = 1000000;
int d[N + 1], p[N + 1], n, m, s[M << 2], z[M << 2];
void sl(int id, int a, int b) {
  if (z[id] == 0) return;
  s[a] += z[id];
  z[a] += z[id];
  s[b] += z[id];
  z[b] += z[id];
  z[id] = 0;
}
void rm(int x, int y, int v, int l = 1, int r = M, int id = 1) {
  if (l > y || r < x) return;
  if (l >= x && r <= y) {
    s[id] += v;
    z[id] += v;
    return;
  }
  int m = l + r >> 1, a = id << 1, b = a | 1;
  sl(id, a, b);
  rm(x, y, v, l, m, a);
  rm(x, y, v, m + 1, r, b);
  s[id] = min(s[a], s[b]);
}
int gt(int l = 1, int r = M, int id = 1) {
  if (l == r) return l;
  int m = l + r >> 1, a = id << 1, b = a | 1;
  sl(id, a, b);
  if (s[b] < 0) return gt(m + 1, r, b);
  return gt(l, m, a);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < (int)(n + 1); ++i) {
    scanf("%d", d + i);
    rm(1, d[i], -1);
  }
  for (int i = 1; i < (int)(m + 1); ++i) {
    scanf("%d", p + i);
    rm(1, p[i], 1);
  }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < (int)(q); ++i) {
    int o, j, v;
    scanf("%d%d%d", &o, &j, &v);
    if (o == 1) {
      rm(1, d[j], 1);
      d[j] = v;
      rm(1, d[j], -1);
    } else {
      rm(1, p[j], -1);
      p[j] = v;
      rm(1, p[j], 1);
    }
    printf("%d\n", s[1] >= 0 ? -1 : gt());
  }
}
