#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int cnt[300009];
int a[300009], b[300009];
const int N = 1e6;
int s[N << 2], lazy[N << 2];
void shift(int nd) {
  int& ret = lazy[nd];
  if (!ret) return;
  s[nd << 1] += ret;
  lazy[nd << 1] += ret;
  s[nd << 1 | 1] += ret;
  lazy[nd << 1 | 1] += ret;
  ret = 0;
}
void inc(int l, int r, int v, int nd, int x, int y) {
  if (l > y or x > r) return;
  if (l <= x and y <= r) {
    s[nd] += v;
    lazy[nd] += v;
    return;
  }
  int mid = (x + y) >> 1;
  shift(nd);
  inc(l, r, v, nd << 1, x, mid);
  inc(l, r, v, nd << 1 | 1, mid + 1, y);
  s[nd] = min(s[nd << 1], s[nd << 1 | 1]);
}
int tap(int nd, int x, int y) {
  if (s[nd] >= 0) return -1;
  if (x == y) return x;
  int mid = (x + y) >> 1;
  shift(nd);
  int i1 = tap(nd << 1 | 1, mid + 1, y);
  if (~i1) return i1;
  return tap(nd << 1, x, mid);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", a + i), inc(1, a[i], -1, 1, 1, N);
  for (int i = 1; i <= m; i++) scanf("%d", b + i), inc(1, b[i], +1, 1, 1, N);
  int q;
  scanf("%d", &q);
  while (q--) {
    int t, p, v;
    scanf("%d%d%d", &t, &p, &v);
    if (t == 1) {
      inc(1, a[p], +1, 1, 1, N);
      a[p] = v;
      inc(1, a[p], -1, 1, 1, N);
    } else {
      inc(1, b[p], -1, 1, 1, N);
      b[p] = v;
      inc(1, b[p], +1, 1, 1, N);
    }
    printf("%d\n", tap(1, 1, N));
  }
  return 0;
}
