#include <bits/stdc++.h>
using namespace std;
const int N = 1e3;
const int maxn = 3e5 + 5;
int n, m, q;
int a[maxn], b[maxn], c[N * N + 100][2];
int cnta[N + 5][N], cntb[N + 5][N], ans[N + 5];
bool ok[N + 5];
void work(int b) {
  int cnt1 = 0, cnt2 = 0;
  for (int i = N - 1; i >= 0; i--) {
    cnt1 += cnta[b][i];
    cnt2 += cntb[b][i];
    if (cnt1 > cnt2) {
      ok[b] = false;
      ans[b] = b * N + i;
      return;
    }
  }
  ok[b] = true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    cnta[a[i] / N][a[i] % N]++;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    cntb[b[i] / N][b[i] % N]++;
  }
  for (int i = 0; i < N + 5; i++) work(i);
  scanf("%d", &q);
  while (q--) {
    int op, pos, x;
    scanf("%d%d%d", &op, &pos, &x);
    if (op == 1) {
      cnta[a[pos] / N][a[pos] % N]--;
      work(a[pos] / N);
      cnta[x / N][x % N]++;
      work(x / N);
      a[pos] = x;
    } else {
      cntb[b[pos] / N][b[pos] % N]--;
      work(b[pos] / N);
      cntb[x / N][x % N]++;
      work(x / N);
      b[pos] = x;
    }
    bool flag = false;
    for (int i = N + 5 - 1; i >= 0; i--) {
      if (!ok[i]) {
        printf("%d\n", ans[i]);
        flag = true;
        break;
      }
    }
    if (!flag) puts("-1");
  }
  return 0;
}
